resterror

package
v0.0.0-...-08b9edc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnauthorized = errorx.CommonErrors.NewType("unauthorized")
	ErrForbidden    = errorx.CommonErrors.NewType("forbidden")
	ErrBadRequest   = errorx.CommonErrors.NewType("bad_request")
	ErrNotFound     = errorx.CommonErrors.NewType("not_found")
)

Functions

func ErrorHandlerFn

func ErrorHandlerFn() gin.HandlerFunc

ErrorHandlerFn creates a handler func that turns (last) error in the context into an APIError json response. In handlers, `c.Error(err)` can be used to attach the error to the context. When error is attached in the context: - The handler can optionally assign the HTTP status code. - The handler must not self-generate a response body.

func HTTPCodeProperty

func HTTPCodeProperty(code int) (errorx.Property, int)

Types

type ErrorResponse

type ErrorResponse struct {
	Error    bool   `json:"error"`
	Message  string `json:"message"`
	Code     string `json:"code"`
	FullText string `json:"full_text"`
}

func NewErrorResponse

func NewErrorResponse(err error) ErrorResponse

Jump to

Keyboard shortcuts

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