errors

package
v0.0.0-...-cf93416 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMethodNotAllowed = &ErrorResponse{HTTPStatusCode: 405, StatusText: "Method not allowed."} //nolint

ErrMethodNotAllowed is default 405 router method not allowed

View Source
var ErrNotFound = &ErrorResponse{HTTPStatusCode: 404, StatusText: "Page not found."} //nolint

ErrNotFound is default router page not found

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Err            error `json:"-"` // low-level runtime error
	HTTPStatusCode int   `json:"-"` // http response status code

	StatusText string `json:"status"`          // user-level status message
	ErrorText  string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrorResponse represents custom error response with statusText and error description

func ErrorForbidden

func ErrorForbidden(err error) *ErrorResponse

ErrorForbidden return 403 with given error text

func ErrorInternalServer

func ErrorInternalServer(err error) *ErrorResponse

ErrorInternalServer returns error response with status=500 and given error

func ErrorInvalidRequest

func ErrorInvalidRequest(err error) *ErrorResponse

ErrorInvalidRequest return error response with status = 400 and given error

func ErrorNotAcceptable

func ErrorNotAcceptable(err error) *ErrorResponse

ErrorNotAcceptable return 406 with given error text

func ErrorNotFound

func ErrorNotFound(err error) *ErrorResponse

ErrorNotFound return 404 with given error text

func ErrorUnauthorized

func ErrorUnauthorized(err error) *ErrorResponse

ErrorUnauthorized return 401 with given error text

func (*ErrorResponse) Render

Render realization method for render.renderer

Jump to

Keyboard shortcuts

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