Skip to content

Commit fd9c92b

Browse files
fix: Add errors package import
Co-Authored-By: [email protected] <[email protected]>
1 parent 763270a commit fd9c92b

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

jsonata.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package jsonata
66

77
import (
88
"encoding/json"
9+
"errors"
910
"fmt"
1011
"reflect"
1112
"sync"
@@ -221,7 +222,7 @@ func (e *Expr) String() string {
221222
// EvalString evaluates a JSONata expression string with optional context
222223
func EvalString(expr string, context ...interface{}) (interface{}, error) {
223224
if expr == "" {
224-
return nil, fmt.Errorf("empty expression string")
225+
return nil, errors.New("empty expression string")
225226
}
226227

227228
e, err := Compile(expr)
@@ -245,12 +246,12 @@ func EvalString(expr string, context ...interface{}) (interface{}, error) {
245246
// Assert evaluates a condition and returns an error if it's false
246247
func Assert(condition interface{}, message ...interface{}) (interface{}, error) {
247248
if condition == nil {
248-
return nil, fmt.Errorf("first argument of assert cannot be null")
249+
return nil, errors.New("first argument of assert cannot be null")
249250
}
250251

251252
cond, ok := jtypes.AsBool(reflect.ValueOf(condition))
252253
if !ok {
253-
return nil, fmt.Errorf("first argument of assert must be a boolean")
254+
return nil, errors.New("first argument of assert must be a boolean")
254255
}
255256

256257
if !cond {
@@ -269,7 +270,7 @@ func Assert(condition interface{}, message ...interface{}) (interface{}, error)
269270
// Error creates an error with the given message
270271
func Error(message interface{}) (interface{}, error) {
271272
if message == nil {
272-
return nil, fmt.Errorf("error")
273+
return nil, errors.New("error")
273274
}
274275

275276
msg, ok := jtypes.AsString(reflect.ValueOf(message))

0 commit comments

Comments
 (0)