File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -283,7 +283,7 @@ func registerMathFunc() {
283283 if v , e := cast .ToFloat64 (args [0 ], cast .CONVERT_SAMEKIND ); e == nil {
284284 r := math .Log (v )
285285 if math .IsNaN (r ) {
286- return nil , true
286+ return fmt . Errorf ( "The argument must be a strictly positive number but got %v" , v ) , true
287287 } else {
288288 return r , true
289289 }
@@ -316,7 +316,7 @@ func registerMathFunc() {
316316 if ! math .IsNaN (r ) {
317317 return r , true
318318 }
319- return nil , true
319+ return fmt . Errorf ( "The argument must be a strictly positive number but got %v" , v ) , true
320320 },
321321 val : func (_ api.FunctionContext , args []ast.Expr ) error {
322322 if len (args ) != 1 && len (args ) != 2 {
@@ -474,7 +474,7 @@ func registerMathFunc() {
474474 if v , e := cast .ToFloat64 (args [0 ], cast .CONVERT_SAMEKIND ); e == nil {
475475 r := math .Sqrt (v )
476476 if math .IsNaN (r ) {
477- return nil , true
477+ return fmt . Errorf ( "The argument must be a positive number but got %v" , v ) , true
478478 } else {
479479 return r , true
480480 }
Original file line number Diff line number Diff line change @@ -164,9 +164,9 @@ func TestFuncMath(t *testing.T) {
164164 10 ,
165165 float64 (- 10 ),
166166 math .Exp (- 10 ),
167- nil ,
168- nil ,
169- nil ,
167+ fmt . Errorf ( "The argument must be a strictly positive number but got -10" ) ,
168+ fmt . Errorf ( "The argument must be a strictly positive number but got -10" ) ,
169+ fmt . Errorf ( "The argument must be a positive number but got -10" ) ,
170170 float64 (100 ),
171171 2 ,
172172 - 10 ,
@@ -234,9 +234,9 @@ func TestFuncMath(t *testing.T) {
234234 float64 (10.5 ),
235235 float64 (- 10 ),
236236 math .Exp (- 10.5 ),
237- nil ,
238- nil ,
239- nil ,
237+ fmt . Errorf ( "The argument must be a strictly positive number but got -10.5" ) ,
238+ fmt . Errorf ( "The argument must be a strictly positive number but got -10.5" ) ,
239+ fmt . Errorf ( "The argument must be a positive number but got -10.5" ) ,
240240 110.25 ,
241241 fmt .Errorf ("Expect int type for the first operand but got -10.5" ),
242242 fmt .Errorf ("Expect int type for the first operand but got -10.5" ),
You can’t perform that action at this time.
0 commit comments