writeError writes an OpenAI-style error envelope.
(c echo.Context, status int, message string)
| 646 | |
| 647 | // writeError writes an OpenAI-style error envelope. |
| 648 | func writeError(c echo.Context, status int, message string) error { |
| 649 | return c.JSON(status, ErrorResponse{Error: ErrorDetail{ |
| 650 | Message: message, |
| 651 | Type: errTypeFor(status), |
| 652 | }}) |
| 653 | } |
| 654 | |
| 655 | func errTypeFor(status int) string { |
| 656 | if status >= 500 { |