errorsx

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternalError = NewHTTPError(500, "Internal Error")
	ErrInvalidParam  = NewHTTPError(400, "Bad Request")
	// ErrUnauthorized ...
	ErrUnauthorized = NewHTTPError(401, "Unauthorized")
	// ErrForbidden ...
	ErrForbidden = NewHTTPError(403, "Forbidden")
	// ErrNotFound ...
	ErrNotFound          = NewHTTPError(404, "Request Not Found")
	InvalidDataInRequest = "invalid data json in request"
	// ResponseError  export common response error, can use addErr to add error replace default error
	RespnseError = NewHTTPError(4000, "Response Error")
)

Functions

func ErrorMessage

func ErrorMessage(err error) (code int, message map[string]interface{})

ErrorMessage returns the code and message for Gins JSON helpers

func NewWithDesc

func NewWithDesc(e error, desc string) error

NewWithDesc ...

func NewWithExtras

func NewWithExtras(e error, desc string, extra map[string]interface{}) error

NewWithExtras ...

Types

type HTTPError

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

HTTPError ...

func NewHTTPError

func NewHTTPError(code int, errStr string, args ...string) *HTTPError

NewHTTPError ...

func (*HTTPError) AddDesc

func (e *HTTPError) AddDesc(desc string) *HTTPError

AddDesc ...

func (*HTTPError) AddErr

func (e *HTTPError) AddErr(err error) *HTTPError

AddErr ...

func (*HTTPError) Code

func (e *HTTPError) Code() int

Code ...

func (*HTTPError) Desc

func (e *HTTPError) Desc() string

Desc ...

func (*HTTPError) Error

func (e *HTTPError) Error() string

Error ...

func (*HTTPError) Extra

func (e *HTTPError) Extra() map[string]interface{}

Extra ...

func (*HTTPError) Message

func (e *HTTPError) Message() string

type IHTTPError

type IHTTPError interface {
	Code() int
	Error() string
	Message() string
	Desc() string
	Extra() map[string]interface{}
}

Jump to

Keyboard shortcuts

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