enum

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorNum

type ErrorNum interface {
	WithError(err error) ErrorNum
	GetError() error

	WithContext(ctx context.Context) ErrorNum
	Context() context.Context

	WithCode(code int) ErrorNum
	GetCode() int

	WithMsg(desc string) ErrorNum
	GetMsg() string

	WithHttpCode(code int) ErrorNum
	GetHttpCode() int
}
var (
	IllegalParam ErrorNum = ErrorNumEntry{
		HttpCode: http.StatusBadRequest,
		Code:     400,
		Msg:      "illegal parameter",
	}

	Unauthorized ErrorNum = ErrorNumEntry{
		HttpCode: http.StatusUnauthorized,
		Code:     401,
		Msg:      "unauthorized",
	}

	Success ErrorNum = ErrorNumEntry{
		HttpCode: http.StatusOK,
		Code:     200,
		Msg:      "success",
	}

	Forbidden ErrorNum = ErrorNumEntry{
		HttpCode: http.StatusForbidden,
		Code:     403,
		Msg:      "forbidden",
	}

	ErrorExecuteFunc ErrorNum = ErrorNumEntry{
		HttpCode: http.StatusBadRequest,
		Code:     500,
		Msg:      "execute func error",
	}

	ErrorGrpcConnect ErrorNum = ErrorNumEntry{
		HttpCode: http.StatusInternalServerError,
		Code:     500,
		Msg:      "grpc connect error",
	}
)

type ErrorNumEntry

type ErrorNumEntry struct {
	Code int    // 业务码
	Msg  string // 美化描述

	HttpCode int
	// contains filtered or unexported fields
}

func NewError added in v0.0.7

func NewError(code int, msg string) ErrorNumEntry

func NewErrorFromGrpcStatus added in v0.0.7

func NewErrorFromGrpcStatus(s *status.Status) ErrorNumEntry

func (ErrorNumEntry) Context

func (e ErrorNumEntry) Context() context.Context

func (ErrorNumEntry) GetCode

func (e ErrorNumEntry) GetCode() int

func (ErrorNumEntry) GetError

func (e ErrorNumEntry) GetError() error

func (ErrorNumEntry) GetHttpCode

func (e ErrorNumEntry) GetHttpCode() int

func (ErrorNumEntry) GetMsg

func (e ErrorNumEntry) GetMsg() string

func (ErrorNumEntry) WithCode

func (e ErrorNumEntry) WithCode(code int) ErrorNum

func (ErrorNumEntry) WithContext

func (e ErrorNumEntry) WithContext(ctx context.Context) ErrorNum

func (ErrorNumEntry) WithError

func (e ErrorNumEntry) WithError(err error) ErrorNum

func (ErrorNumEntry) WithHttpCode

func (e ErrorNumEntry) WithHttpCode(code int) ErrorNum

func (ErrorNumEntry) WithMsg

func (e ErrorNumEntry) WithMsg(desc string) ErrorNum

Jump to

Keyboard shortcuts

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