Skip to content

Commit 763270a

Browse files
fix: Replace fmt.Errorf with errors.New for simple error messages
Co-Authored-By: [email protected] <[email protected]>
1 parent 5e0906b commit 763270a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

jsonata.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (e *Expr) Eval(data interface{}) (interface{}, error) {
149149
}
150150

151151
if !result.CanInterface() {
152-
return nil, fmt.Errorf("Eval returned a non-interface value")
152+
return nil, errors.New("Eval returned a non-interface value")
153153
}
154154

155155
if result.Kind() == reflect.Ptr && result.IsNil() {
@@ -260,7 +260,7 @@ func Assert(condition interface{}, message ...interface{}) (interface{}, error)
260260
msg = str
261261
}
262262
}
263-
return nil, fmt.Errorf(msg)
263+
return nil, errors.New(msg)
264264
}
265265

266266
return true, nil
@@ -274,10 +274,10 @@ func Error(message interface{}) (interface{}, error) {
274274

275275
msg, ok := jtypes.AsString(reflect.ValueOf(message))
276276
if !ok {
277-
return nil, fmt.Errorf("argument of error must be a string")
277+
return nil, errors.New("argument of error must be a string")
278278
}
279279

280-
return nil, fmt.Errorf(msg)
280+
return nil, errors.New(msg)
281281
}
282282

283283
// Single ensures a sequence contains exactly one value
@@ -305,7 +305,7 @@ func Single(values interface{}, message ...interface{}) (interface{}, error) {
305305
msg = str
306306
}
307307
}
308-
return nil, fmt.Errorf(msg)
308+
return nil, errors.New(msg)
309309
}
310310

311311
if length > 1 {
@@ -315,7 +315,7 @@ func Single(values interface{}, message ...interface{}) (interface{}, error) {
315315
msg = str
316316
}
317317
}
318-
return nil, fmt.Errorf(msg)
318+
return nil, errors.New(msg)
319319
}
320320

321321
return v.Index(0).Interface(), nil

0 commit comments

Comments
 (0)