errors

package
v0.0.0-...-c3e479f Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServerExited = fmt.Errorf("server exited")

Functions

func GetGeneralResponseCode

func GetGeneralResponseCode(response ErrorResponse) int

GetGeneralResponseCode returns the most common error code class in response

func HttpCodeForDaoError

func HttpCodeForDaoError(err error) int

HttpCodeForDaoError returns http code for corresponding dao error

Types

type DaoError

type DaoError struct {
	Err           error
	Message       string
	NotFound      bool
	BadValidation bool
	AlreadyExists bool
}

func (*DaoError) Error

func (e *DaoError) Error() string

func (*DaoError) Unwrap

func (e *DaoError) Unwrap() error

func (*DaoError) Wrap

func (e *DaoError) Wrap(err error)

type ErrorResponse

type ErrorResponse struct {
	Errors []HandlerError `json:"errors"`
}

func NewErrorResponse

func NewErrorResponse(code int, title string, detail string) ErrorResponse

func NewErrorResponseFromEchoError

func NewErrorResponseFromEchoError(echoErr *echo.HTTPError) ErrorResponse

NewErrorResponseFromEchoError creates a new ErrorResponse instance from an echo.HTTPError instance

func NewErrorResponseFromError

func NewErrorResponseFromError(title string, errs ...error) ErrorResponse

NewErrorResponseFromError creates a new ErrorResponse from a list of errors.

func (ErrorResponse) Error

func (er ErrorResponse) Error() string

ErrorResponse makes it compatible with `error` interface.

type HandlerError

type HandlerError struct {
	Status int    `json:"status,omitempty"` // HTTP status code applicable to the error
	Title  string `json:"title,omitempty"`  // A summary of the problem
	Detail string `json:"detail,omitempty"` // An explanation specific to the problem
}

func (HandlerError) Error

func (er HandlerError) Error() string

Error makes it compatible with `error` interface.

Jump to

Keyboard shortcuts

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