errorresp

package
v1.0.6-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2022 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrResp

func ErrResp(e error) (httpendpoints.Responser, error)

ErrResp 根据 error 转为一个 http error response.

func ErrWrite

func ErrWrite(e error, w http.ResponseWriter) error

ErrWrite 根据 error 写入标准错误格式

func IsNotFound

func IsNotFound(e error) bool

IsNotFound .

Types

type APIError

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

APIError .

func New

func New(options ...Option) *APIError

New .

func (*APIError) AccessDenied

func (e *APIError) AccessDenied() *APIError

AccessDenied .

func (*APIError) AlreadyExists

func (e *APIError) AlreadyExists() *APIError

AlreadyExists .

func (*APIError) Code

func (e *APIError) Code() string

Code .

func (*APIError) Error

func (e *APIError) Error() string

Error .

func (*APIError) ErrorVerificationCode

func (e *APIError) ErrorVerificationCode(err error) *APIError

ErrorVerificationCode .

func (*APIError) HTTPCode

func (e *APIError) HTTPCode() int

HTTPCode ...

func (*APIError) InternalError

func (e *APIError) InternalError(err error) *APIError

InternalError .

func (*APIError) InvalidParameter

func (e *APIError) InvalidParameter(err interface{}) *APIError

InvalidParameter .

func (*APIError) InvalidState

func (e *APIError) InvalidState(err string) *APIError

InvalidState .

func (*APIError) MissingParameter

func (e *APIError) MissingParameter(err string) *APIError

MissingParameter .

func (*APIError) NotFound

func (e *APIError) NotFound() *APIError

NotFound .

func (*APIError) NotLogin

func (e *APIError) NotLogin() *APIError

NotLogin .

func (*APIError) Render

func (e *APIError) Render(localeResource i18n.LocaleResource) string

Render .

func (*APIError) ToResp

func (e *APIError) ToResp() httpendpoints.Responser

ToResp 根据 APIError 转为一个 http error response.

func (*APIError) Write

func (e *APIError) Write(w http.ResponseWriter) error

Write 将错误写入 http.ResponseWriter

type MetaMessage

type MetaMessage struct {
	Key     string
	Args    []interface{}
	Default string
}

MetaMessage .

type Option

type Option func(*APIError)

Option 可选参数

func WithCode

func WithCode(httpCode int, code string) Option

WithCode .

func WithMessage

func WithMessage(msg string) Option

WithMessage .

func WithTemplateMessage

func WithTemplateMessage(template, defaultValue string, args ...interface{}) Option

WithTemplateMessage .

Jump to

Keyboard shortcuts

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