MCPcopy Create free account
hub / github.com/kataras/iris / handleJSONError

Function handleJSONError

x/errors/errors.go:406–423  ·  view source on GitHub ↗
(ctx *context.Context, err error)

Source from the content-addressed store, hash-verified

404}
405
406func handleJSONError(ctx *context.Context, err error) bool {
407 var syntaxErr *json.SyntaxError
408 if errors.As(err, &syntaxErr) {
409 InvalidArgument.Details(ctx, "unable to parse body", "syntax error at byte offset %d", syntaxErr.Offset)
410 return true
411 }
412
413 var unmarshalErr *json.UnmarshalTypeError
414 if errors.As(err, &unmarshalErr) {
415 InvalidArgument.Details(ctx, "unable to parse body", "unmarshal error for field %q", unmarshalErr.Field)
416 return true
417 }
418
419 return false
420 // else {
421 // InvalidArgument.Details(ctx, "unable to parse body", err.Error())
422 // }
423}
424
425var (
426 // ErrUnexpected is the HTTP error which sent to the client

Callers 1

HandleErrorFunction · 0.85

Calls 2

DetailsMethod · 0.80
AsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…