Skip to content

Errors & HTTP status ​

core.Error(c, err) replies with the status of the first error in err's chain that has an HTTPStatus() int method, and with that error's message.

ErrorStatusMessage
core.NewError(status, message)statusmessage, or the standard status text when empty
database.ErrInvalidInput400invalid input
security.ErrInvalidToken401invalid token
database.ErrNotFound404not found
database.ErrConflict409conflict
a type with HTTPStatus() intwhat it returnsits Error()
anything else500internal server error

Database errors ​

What happened in PostgreSQLBecomes
a unique value already existsErrConflict
Save with a stale versionErrConflict
no rowErrNotFound
any data error: a malformed value (an invalid UUID...), a value too long for its column, a number out of range, an invalid dateErrInvalidInput
a null in a not null column, a broken foreign key, a failed checkErrInvalidInput
an update or insert with nothing to writeErrInvalidInput

Reply codes ​

ConstantcodeUsed by default for
core.SuccessCode1status below 400
core.WarningCode2status 400–499
core.DangerCode3status 500 and above

The full error, with everything wrapped around it, is written to the request's log line, never to the client.

Released under the MIT License.