package
0.0.0-20241021075312-9ecd722819af
Repository: https://github.com/navikt/nada-backend.git
Documentation: pkg.go.dev
# README
We have copied the following package from: https://github.com/gilcrest/diygoapi, where Dan Gillis has written an excellent article explaining the thinking around the design of this package here: https://gilcrestian.medium.com/rest-api-error-handling-in-go-dab62323add5.
# Functions
E builds an error value from its arguments.
HTTPErrorResponse takes a writer, error and a logger, performs a type switch to determine if the type is an Error (which meets the Error interface as defined in this package), then sends the Error as a response to the client.
KindIs reports whether err is an *Error of the given Kind.
Match compares its two error arguments.
OpStack returns the op stack information for an error.
Str returns an error that formats as the given text.
TopError recursively unwraps all errors and retrieves the topmost error.
# Constants
Link target does not exist.
Error from database.
Item already exists.
Internal error or inconsistency.
Invalid operation for this type of item.
Invalid Request.
External I/O error such as network failure.
Item does not exist.
Unclassified error.
Information withheld.
Unanticipated error.
Unauthenticated Request.
Unauthorized is used when a user is authenticated, but is not authorized to access the resource.
Unsupported Media Type.
Input validation error.
# Structs
Error is the type that implements the error interface.
ErrResponse is used as the Response Body.
ServiceError has fields for Service errors.
# Type aliases
Code is a human-readable, short representation of the error.
InputUnwanted is an error type that can be used when validating input fields that have a value, but should not.
Kind defines the kind of error this is, mostly for use by systems such as FUSE that must act differently depending on the error.
MissingField is an error type that can be used when validating input fields that do not have a value, but should.
Op describes an operation, usually as the package and method, such as "key/server.Lookup".
Parameter represents the parameter related to the error.
Realm is a description of a protected area, used in the WWW-Authenticate header.
UserName is a string representing a user.