Errors
Zinc uses HTTPError for structured HTTP failures.
HTTPError
Section titled “HTTPError”type HTTPError struct { Code int Message string Cause error Meta zinc.Map Headers http.Header}Useful methods:
WithMessageWithCauseWithMetaWithHeader
Create errors
Section titled “Create errors”return zinc.NewError(zinc.StatusBadRequest).WithMessage("invalid payload")Predefined errors
Section titled “Predefined errors”Zinc includes ready-made errors for common HTTP statuses, including:
ErrBadRequestErrUnauthorizedErrForbiddenErrNotFoundErrMethodNotAllowedErrTooManyRequestsErrInternalServerError
Error handling hook
Section titled “Error handling hook”Set Config.ErrorHandler to control how returned errors are rendered.
That is the right place to implement a project-wide JSON error envelope.
