e

package
v0.0.0-...-7f880ae Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotFound           = &ErrorCode{Code: http.StatusNotFound, Type: "NotFound"}
	NotAcceptable      = &ErrorCode{Code: http.StatusNotAcceptable, Type: "NotAcceptable"}
	Unknown            = &ErrorCode{Code: http.StatusInternalServerError, Type: "Unknown"}
	Internal           = &ErrorCode{Code: http.StatusInternalServerError, Type: "InternalError"}
	TooManyRequests    = &ErrorCode{Code: http.StatusTooManyRequests, Type: "TooManyRequests"}
	Unauthorized       = &ErrorCode{Code: http.StatusUnauthorized, Type: "Unauthorized"}
	Forbidden          = &ErrorCode{Code: http.StatusForbidden, Type: "Forbidden"}
	Timeout            = &ErrorCode{Code: http.StatusRequestTimeout, Type: "Timeout"}
	Unavailable        = &ErrorCode{Code: http.StatusServiceUnavailable, Type: "Unavailable"}
	Aborted            = &ErrorCode{Code: http.StatusInternalServerError, Type: "Aborted"}
	DataLoss           = &ErrorCode{Code: http.StatusInternalServerError, Type: "DataLoss"}
	Unimplemented      = &ErrorCode{Code: http.StatusNotImplemented, Type: "Unimplemented"}
	FailedPrecondition = &ErrorCode{Code: http.StatusPreconditionFailed, Type: "FailedPrecondition"}
	Conflict           = &ErrorCode{Code: http.StatusBadRequest, Type: "Conflict"}
	OutOfRange         = &ErrorCode{Code: http.StatusBadRequest, Type: "OutOfRange"}
	InvalidArgument    = &ErrorCode{Code: http.StatusBadRequest, Type: "InvalidArgument"}
)

Functions

func ConvertErrorCodeToGrpcCode

func ConvertErrorCodeToGrpcCode(err *Error) *status.Status

ConvertErrorCodeToGrpcCode 将自定义业务错误码转换为 gRPC 标准错误码

Types

type ApiError

type ApiError interface {
	GetCode() int
	GetType() string
	GetMessage() string
	GetCause() error
	IsInternalError() bool
	Error() string
	GRPCStatus() *status.Status
	SetMessage(string)
	SetCode(int)
}

type Error

type Error = apiError

func ConvertErrorToErrorCode

func ConvertErrorToErrorCode(err error) *Error

func ConvertGrpcCodeToErrorCode

func ConvertGrpcCodeToErrorCode(s *status.Status) *Error

func NewApiError

func NewApiError(errCode *ErrorCode, msg string, err ...error) *Error

func NewInternalError

func NewInternalError(err error) *Error

type ErrorCode

type ErrorCode struct {
	Code int
	Type string
}

Jump to

Keyboard shortcuts

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