Documentation
¶
Overview ¶
Package errors provides helper functions for handling errors with specific HTTP status codes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromGorm ¶ added in v1.7.10
FromGorm turns a query error into a status error: a missing row is a 404, anything else a 500. notFound is required so the client is not shown gorm's own wording.
Not every missing row is a 404 — GetBookmarks returns an empty list, ResetPassword treats it as success — so this is only for the cases where it is.
func WithStatus ¶
WithStatus creates a new error with a specific HTTP status code and a given error message. It maps the HTTP status code to a corresponding gRPC status code. If the HTTP status code is not recognized, it logs a warning and uses gRPC's Unknown code. It returns a gRPC error with the mapped gRPC status code and the original error message.
Types ¶
This section is empty.