errors

package
v0.0.0-...-3fb87e6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(logger log.Logger) routing.Handler

Handler creates a middleware that handles panics and errors encountered during HTTP request processing.

Types

type ErrorResponse

type ErrorResponse struct {
	Status  int         `json:"status"`
	Message string      `json:"message"`
	Details interface{} `json:"details,omitempty"`
}

ErrorResponse is the response that represents an error.

func BadRequest

func BadRequest(msg string) ErrorResponse

BadRequest creates a new error response representing a bad request (HTTP 400)

func Forbidden

func Forbidden(msg string) ErrorResponse

Forbidden creates a new error response representing an authorization failure (HTTP 403)

func InternalServerError

func InternalServerError(msg string) ErrorResponse

InternalServerError creates a new error response representing an internal server error (HTTP 500)

func InvalidInput

func InvalidInput(errs validation.Errors) ErrorResponse

InvalidInput creates a new error response representing a data validation error (HTTP 400).

func NotFound

func NotFound(msg string) ErrorResponse

NotFound creates a new error response representing a resource-not-found error (HTTP 404)

func Unauthorized

func Unauthorized(msg string) ErrorResponse

Unauthorized creates a new error response representing an authentication/authorization failure (HTTP 401)

func (ErrorResponse) Error

func (e ErrorResponse) Error() string

Error is required by the error interface.

func (ErrorResponse) StatusCode

func (e ErrorResponse) StatusCode() int

StatusCode is required by routing.HTTPError interface.

Jump to

Keyboard shortcuts

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