@@ -17,7 +17,10 @@ fn as_number(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError
1717 kind : Some ( Kind :: BoolValue ( value) ) ,
1818 } ] = values
1919 else {
20- return Err ( RuntimeError :: default ( ) ) ;
20+ return Err ( RuntimeError :: simple (
21+ "InvalidArgumentRuntimeError" ,
22+ format ! ( "Expected a boolean value but received {:?}" , values) ,
23+ ) ) ;
2124 } ;
2225
2326 Ok ( Value {
@@ -30,7 +33,10 @@ fn as_text(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError>
3033 kind : Some ( Kind :: BoolValue ( value) ) ,
3134 } ] = values
3235 else {
33- return Err ( RuntimeError :: default ( ) ) ;
36+ return Err ( RuntimeError :: simple (
37+ "InvalidArgumentRuntimeError" ,
38+ format ! ( "Expected a boolean value but received {:?}" , values) ,
39+ ) ) ;
3440 } ;
3541
3642 Ok ( Value {
@@ -43,7 +49,10 @@ fn from_number(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeErr
4349 kind : Some ( Kind :: NumberValue ( number) ) ,
4450 } ] = values
4551 else {
46- return Err ( RuntimeError :: default ( ) ) ;
52+ return Err ( RuntimeError :: simple (
53+ "InvalidArgumentRuntimeError" ,
54+ format ! ( "Expected a number value but received {:?}" , values) ,
55+ ) ) ;
4756 } ;
4857
4958 let is_zero = number == & 0.0 ;
@@ -58,12 +67,20 @@ fn from_text(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError
5867 kind : Some ( Kind :: StringValue ( text) ) ,
5968 } ] = values
6069 else {
61- return Err ( RuntimeError :: default ( ) ) ;
70+ return Err ( RuntimeError :: simple (
71+ "InvalidArgumentRuntimeError" ,
72+ format ! ( "Expected a string value but received {:?}" , values) ,
73+ ) ) ;
6274 } ;
6375
6476 let bool: bool = match text. to_lowercase ( ) . parse ( ) {
6577 Ok ( value) => value,
66- Err ( _) => return Err ( RuntimeError :: default ( ) ) ,
78+ Err ( _) => {
79+ return Err ( RuntimeError :: simple (
80+ "InvalidArgumentRuntimeError" ,
81+ format ! ( "Failed to parse boolean from string: {:?}" , text) ,
82+ ) )
83+ }
6784 } ;
6885
6986 Ok ( Value {
@@ -78,7 +95,10 @@ fn is_equal(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError>
7895 kind : Some ( Kind :: BoolValue ( rhs) ) ,
7996 } ] = values
8097 else {
81- return Err ( RuntimeError :: default ( ) ) ;
98+ return Err ( RuntimeError :: simple (
99+ "InvalidArgumentRuntimeError" ,
100+ format ! ( "Expected two boolean values but received {:?}" , values) ,
101+ ) ) ;
82102 } ;
83103
84104 Ok ( Value {
@@ -91,7 +111,10 @@ fn negate(values: &[Value], _ctx: &mut Context) -> Result<Value, RuntimeError> {
91111 kind : Some ( Kind :: BoolValue ( value) ) ,
92112 } ] = values
93113 else {
94- return Err ( RuntimeError :: default ( ) ) ;
114+ return Err ( RuntimeError :: simple (
115+ "InvalidArgumentRuntimeError" ,
116+ format ! ( "Expected a boolean value but received {:?}" , values) ,
117+ ) ) ;
95118 } ;
96119
97120 Ok ( Value {
0 commit comments