httperror

package
v0.0.0-...-c846bbc Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultReportErrorFunc

func SetDefaultReportErrorFunc(fn ReportErrorFunc)

SetDefaultReportErrorFunc sets a new defaultReportErrorFunc to report unexpected errors.

Types

type HTTPError

type HTTPError struct {
	StatusCode int    `json:"-"`
	Message    string `json:"error"`
	// Extras contains extra information about the error.
	Extras map[string]interface{} `json:"extras,omitempty"`
	// Err is an optional field that can be used to wrap the original error to pass it forward.
	Err error `json:"-"`
}

func BadRequest

func BadRequest(msg string, originalErr error, extras map[string]interface{}) *HTTPError

func Conflict

func Conflict(msg string, originalErr error, extras map[string]interface{}) *HTTPError

func Forbidden

func Forbidden(msg string, originalErr error, extras map[string]interface{}) *HTTPError

func InternalError

func InternalError(ctx context.Context, msg string, originalErr error, extras map[string]interface{}) *HTTPError

func NewHTTPError

func NewHTTPError(statusCode int, msg string, originalErr error, extras map[string]interface{}) *HTTPError

func NotFound

func NotFound(msg string, originalErr error, extras map[string]interface{}) *HTTPError

func Unauthorized

func Unauthorized(msg string, originalErr error, extras map[string]interface{}) *HTTPError

func UnprocessableEntity

func UnprocessableEntity(msg string, originalErr error, extras map[string]interface{}) *HTTPError

func (*HTTPError) Error

func (h *HTTPError) Error() string

func (*HTTPError) Render

func (e *HTTPError) Render(w http.ResponseWriter)

func (*HTTPError) Unwrap

func (e *HTTPError) Unwrap() error

type ReportError

type ReportError struct {
	// contains filtered or unexported fields
}

ReportError is a struct type used to report unexpected errors.

type ReportErrorFunc

type ReportErrorFunc func(ctx context.Context, err error, msg string)

ReportFunc is a function type used to report unexpected errors.

Jump to

Keyboard shortcuts

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