(ctx *context.Context, err error)
| 404 | } |
| 405 | |
| 406 | func 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 | |
| 425 | var ( |
| 426 | // ErrUnexpected is the HTTP error which sent to the client |
no test coverage detected
searching dependent graphs…