problem

package
v0.0.0-...-9d44915 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2023 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = WithStatus(WithDescription(nil, "resource not found", "the requested resource has not been found"), http.StatusNotFound)

ErrNotFound is thrown whenever the requested resource could not be found.

View Source
var ErrUnauthorized = WithStatus(WithDescription(nil, "unauthorized", "you are unauthorized to access the given endpoint"), http.StatusUnauthorized)

ErrUnauthorized is thrown whenever a user calls an unauthorized endpoint.

View Source
var ErrUnimplemented = WithStatus(WithDescription(nil, "unimplemented endpoint", "the requested endpoint has not yet been implemented"), http.StatusNotImplemented)

ErrUnimplemented is thrown whenever an unimplemented endpoint has been called.

Functions

func AsDescription

func AsDescription(err error) error

AsDescription sets the error content as the error description.

func GetDescription

func GetDescription(err error) (title string, description string)

GetDescription attempts to unwrap the human readable description of the given error. The default HTTP status text for the underlaying probem status is returned if no description has been found.

func GetStatus

func GetStatus(err error) (status int)

GetStatus returns the underlying error status. Statuses are based on the registered IANA statuses. If no status has been found is the default internal server error status code returned. https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

func WithDescription

func WithDescription(err error, title string, description ...string) error

WithDescription wraps a human readable title and description around the given error. The title should represent a short summary of the problem. The details should include details on how to resolve the given error. If multiple details are given they will be joined using a new line character.

func WithStatus

func WithStatus(err error, status int) error

WithStatus wraps the given status around the given error. This status is returned to the client defining the error category.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL