Documentation ¶
Index ¶
- Constants
- Variables
- func BadRequest(reason, message string, eSlice ...error) *errors.Error
- func BadRequestWithMetadata(reason, message string, md map[string]string) *errors.Error
- func Caller(err error) (callers []string)
- func CallerWithSkip(err error, skip int) (callers []string)
- func Cause(err error) error
- func ClientClosed(reason, message string, eSlice ...error) *errors.Error
- func ClientClosedWithMetadata(reason, message string, md map[string]string) *errors.Error
- func Code(err error) int
- func Conflict(reason, message string, eSlice ...error) *errors.Error
- func ConflictWithMetadata(reason, message string, md map[string]string) *errors.Error
- func ErrMessage(key string) string
- func ErrorAccepted(format string, args ...interface{}) *errors.Error
- func ErrorAlreadyReported(format string, args ...interface{}) *errors.Error
- func ErrorBadGateway(format string, args ...interface{}) *errors.Error
- func ErrorBadRequest(format string, args ...interface{}) *errors.Error
- func ErrorCache(format string, args ...interface{}) *errors.Error
- func ErrorClientClose(format string, args ...interface{}) *errors.Error
- func ErrorConflict(format string, args ...interface{}) *errors.Error
- func ErrorConnectionError(format string, args ...interface{}) *errors.Error
- func ErrorContinue(format string, args ...interface{}) *errors.Error
- func ErrorCreated(format string, args ...interface{}) *errors.Error
- func ErrorDb(format string, args ...interface{}) *errors.Error
- func ErrorEarlyHints(format string, args ...interface{}) *errors.Error
- func ErrorEmpty306(format string, args ...interface{}) *errors.Error
- func ErrorExpectationFailed(format string, args ...interface{}) *errors.Error
- func ErrorFailedDependency(format string, args ...interface{}) *errors.Error
- func ErrorFatal(format string, args ...interface{}) *errors.Error
- func ErrorForbidden(format string, args ...interface{}) *errors.Error
- func ErrorFound(format string, args ...interface{}) *errors.Error
- func ErrorGatewayTimeout(format string, args ...interface{}) *errors.Error
- func ErrorGone(format string, args ...interface{}) *errors.Error
- func ErrorHttpVersionNotSupported(format string, args ...interface{}) *errors.Error
- func ErrorIMUsed(format string, args ...interface{}) *errors.Error
- func ErrorInsufficientStorage(format string, args ...interface{}) *errors.Error
- func ErrorInternalError(format string, args ...interface{}) *errors.Error
- func ErrorInternalServer(format string, args ...interface{}) *errors.Error
- func ErrorInvalidParameter(format string, args ...interface{}) *errors.Error
- func ErrorKafka(format string, args ...interface{}) *errors.Error
- func ErrorLengthRequired(format string, args ...interface{}) *errors.Error
- func ErrorLocked(format string, args ...interface{}) *errors.Error
- func ErrorLoopDetected(format string, args ...interface{}) *errors.Error
- func ErrorMethodNotAllowed(format string, args ...interface{}) *errors.Error
- func ErrorMisdirectedRequest(format string, args ...interface{}) *errors.Error
- func ErrorMongo(format string, args ...interface{}) *errors.Error
- func ErrorMovedPermanently(format string, args ...interface{}) *errors.Error
- func ErrorMq(format string, args ...interface{}) *errors.Error
- func ErrorMultiStatus(format string, args ...interface{}) *errors.Error
- func ErrorMultipleChoices(format string, args ...interface{}) *errors.Error
- func ErrorMysql(format string, args ...interface{}) *errors.Error
- func ErrorNetworkAuthenticationRequired(format string, args ...interface{}) *errors.Error
- func ErrorNetworkError(format string, args ...interface{}) *errors.Error
- func ErrorNetworkTimeout(format string, args ...interface{}) *errors.Error
- func ErrorNoContent(format string, args ...interface{}) *errors.Error
- func ErrorNonAuthoritativeInfo(format string, args ...interface{}) *errors.Error
- func ErrorNotAcceptable(format string, args ...interface{}) *errors.Error
- func ErrorNotExtended(format string, args ...interface{}) *errors.Error
- func ErrorNotFound(format string, args ...interface{}) *errors.Error
- func ErrorNotImplemented(format string, args ...interface{}) *errors.Error
- func ErrorNotModified(format string, args ...interface{}) *errors.Error
- func ErrorOk(format string, args ...interface{}) *errors.Error
- func ErrorPanic(format string, args ...interface{}) *errors.Error
- func ErrorPartialContent(format string, args ...interface{}) *errors.Error
- func ErrorPaymentRequired(format string, args ...interface{}) *errors.Error
- func ErrorPermanentRedirect(format string, args ...interface{}) *errors.Error
- func ErrorPreconditionFailed(format string, args ...interface{}) *errors.Error
- func ErrorPreconditionRequired(format string, args ...interface{}) *errors.Error
- func ErrorProcessing(format string, args ...interface{}) *errors.Error
- func ErrorProxyAuthRequired(format string, args ...interface{}) *errors.Error
- func ErrorQueue(format string, args ...interface{}) *errors.Error
- func ErrorRabbitMq(format string, args ...interface{}) *errors.Error
- func ErrorRecordAlreadyExists(format string, args ...interface{}) *errors.Error
- func ErrorRecordNotFound(format string, args ...interface{}) *errors.Error
- func ErrorRedis(format string, args ...interface{}) *errors.Error
- func ErrorRequestEntityTooLarge(format string, args ...interface{}) *errors.Error
- func ErrorRequestFailed(format string, args ...interface{}) *errors.Error
- func ErrorRequestHeaderFieldsTooLarge(format string, args ...interface{}) *errors.Error
- func ErrorRequestNotSupport(format string, args ...interface{}) *errors.Error
- func ErrorRequestTimeout(format string, args ...interface{}) *errors.Error
- func ErrorRequestUriTooLong(format string, args ...interface{}) *errors.Error
- func ErrorRequestedRangeNotSatisfiable(format string, args ...interface{}) *errors.Error
- func ErrorResetContent(format string, args ...interface{}) *errors.Error
- func ErrorSeeOther(format string, args ...interface{}) *errors.Error
- func ErrorServiceUnavailable(format string, args ...interface{}) *errors.Error
- func ErrorSwitchingProtocols(format string, args ...interface{}) *errors.Error
- func ErrorTeapot(format string, args ...interface{}) *errors.Error
- func ErrorTemporaryRedirect(format string, args ...interface{}) *errors.Error
- func ErrorThirdPartyServiceInternalError(format string, args ...interface{}) *errors.Error
- func ErrorThirdPartyServiceInvalidCode(format string, args ...interface{}) *errors.Error
- func ErrorTooEarly(format string, args ...interface{}) *errors.Error
- func ErrorTooManyRequests(format string, args ...interface{}) *errors.Error
- func ErrorUnauthorized(format string, args ...interface{}) *errors.Error
- func ErrorUnavailableForLegalReasons(format string, args ...interface{}) *errors.Error
- func ErrorUnimplemented(format string, args ...interface{}) *errors.Error
- func ErrorUninitialized(format string, args ...interface{}) *errors.Error
- func ErrorUnknown(format string, args ...interface{}) *errors.Error
- func ErrorUnprocessableEntity(format string, args ...interface{}) *errors.Error
- func ErrorUnsupportedMediaType(format string, args ...interface{}) *errors.Error
- func ErrorUpgradeRequired(format string, args ...interface{}) *errors.Error
- func ErrorUseProxy(format string, args ...interface{}) *errors.Error
- func ErrorVariantAlsoNegotiates(format string, args ...interface{}) *errors.Error
- func Forbidden(reason, message string, eSlice ...error) *errors.Error
- func ForbiddenWithMetadata(reason, message string, md map[string]string) *errors.Error
- func FromError(err error) *errors.Error
- func GatewayTimeout(reason, message string, eSlice ...error) *errors.Error
- func GatewayTimeoutWithMetadata(reason, message string, md map[string]string) *errors.Error
- func InternalServer(reason, message string, eSlice ...error) *errors.Error
- func InternalServerWithMetadata(reason, message string, md map[string]string) *errors.Error
- func Is(err, target error) bool
- func IsAccepted(err error) bool
- func IsAlreadyReported(err error) bool
- func IsBadGateway(err error) bool
- func IsBadRequest(err error) bool
- func IsCache(err error) bool
- func IsClientClose(err error) bool
- func IsCode(err error, code int) bool
- func IsConflict(err error) bool
- func IsConnectionError(err error) bool
- func IsContinue(err error) bool
- func IsCreated(err error) bool
- func IsDb(err error) bool
- func IsEarlyHints(err error) bool
- func IsEmpty306(err error) bool
- func IsExpectationFailed(err error) bool
- func IsFailedDependency(err error) bool
- func IsFatal(err error) bool
- func IsForbidden(err error) bool
- func IsFound(err error) bool
- func IsGatewayTimeout(err error) bool
- func IsGone(err error) bool
- func IsHttpVersionNotSupported(err error) bool
- func IsIMUsed(err error) bool
- func IsInsufficientStorage(err error) bool
- func IsInternalError(err error) bool
- func IsInternalServer(err error) bool
- func IsInvalidParameter(err error) bool
- func IsKafka(err error) bool
- func IsLengthRequired(err error) bool
- func IsLocked(err error) bool
- func IsLoopDetected(err error) bool
- func IsMethodNotAllowed(err error) bool
- func IsMisdirectedRequest(err error) bool
- func IsMongo(err error) bool
- func IsMovedPermanently(err error) bool
- func IsMq(err error) bool
- func IsMultiStatus(err error) bool
- func IsMultipleChoices(err error) bool
- func IsMysql(err error) bool
- func IsNetworkAuthenticationRequired(err error) bool
- func IsNetworkError(err error) bool
- func IsNetworkTimeout(err error) bool
- func IsNoContent(err error) bool
- func IsNonAuthoritativeInfo(err error) bool
- func IsNotAcceptable(err error) bool
- func IsNotExtended(err error) bool
- func IsNotFound(err error) bool
- func IsNotImplemented(err error) bool
- func IsNotModified(err error) bool
- func IsOk(err error) bool
- func IsPanic(err error) bool
- func IsPartialContent(err error) bool
- func IsPaymentRequired(err error) bool
- func IsPermanentRedirect(err error) bool
- func IsPreconditionFailed(err error) bool
- func IsPreconditionRequired(err error) bool
- func IsProcessing(err error) bool
- func IsProxyAuthRequired(err error) bool
- func IsQueue(err error) bool
- func IsRabbitMq(err error) bool
- func IsReason(err error, reason string) bool
- func IsRecordAlreadyExists(err error) bool
- func IsRecordNotFound(err error) bool
- func IsRedis(err error) bool
- func IsRequestEntityTooLarge(err error) bool
- func IsRequestFailed(err error) bool
- func IsRequestHeaderFieldsTooLarge(err error) bool
- func IsRequestNotSupport(err error) bool
- func IsRequestTimeout(err error) bool
- func IsRequestUriTooLong(err error) bool
- func IsRequestedRangeNotSatisfiable(err error) bool
- func IsResetContent(err error) bool
- func IsSeeOther(err error) bool
- func IsServiceUnavailable(err error) bool
- func IsSwitchingProtocols(err error) bool
- func IsTeapot(err error) bool
- func IsTemporaryRedirect(err error) bool
- func IsThirdPartyServiceInternalError(err error) bool
- func IsThirdPartyServiceInvalidCode(err error) bool
- func IsTooEarly(err error) bool
- func IsTooManyRequests(err error) bool
- func IsUnauthorized(err error) bool
- func IsUnavailableForLegalReasons(err error) bool
- func IsUnimplemented(err error) bool
- func IsUninitialized(err error) bool
- func IsUnknown(err error) bool
- func IsUnprocessableEntity(err error) bool
- func IsUnsupportedMediaType(err error) bool
- func IsUpgradeRequired(err error) bool
- func IsUseProxy(err error) bool
- func IsVariantAlsoNegotiates(err error) bool
- func Message(err error) string
- func Metadata(err error) (metadata map[string]string, ok bool)
- func NotFound(reason, message string, eSlice ...error) *errors.Error
- func NotFoundWithMetadata(reason, message string, md map[string]string) *errors.Error
- func NotImplemented(reason, message string, eSlice ...error) *errors.Error
- func NotImplementedWithMetadata(reason, message string, md map[string]string) error
- func Println(err error)
- func Reason(err error) string
- func RecoverStack() string
- func ServiceUnavailable(reason, message string, eSlice ...error) *errors.Error
- func ServiceUnavailableWithMetadata(reason, message string, md map[string]string) *errors.Error
- func Stack(err error) (callers []string)
- func StatusOK(reason, message string, eSlice ...error) *errors.Error
- func StatusOKWithMetadata(reason, message string, md map[string]string) *errors.Error
- func TooManyRequests(reason, message string, eSlice ...error) *errors.Error
- func TooManyRequestsWithMetadata(reason, message string, md map[string]string) *errors.Error
- func Unauthorized(reason, message string, eSlice ...error) *errors.Error
- func UnauthorizedWithMetadata(reason, message string, md map[string]string) *errors.Error
- func WrapWithEnumNumber(e *errors.Error, enum Enum) error
- func WrapWithMetadata(e *errors.Error, md map[string]string) error
- type ERROR
- type Enum
- type Error
- func Err(code int, e Enum, msg string) *Error
- func ErrWithMetadata(code int, enum Enum, message string, md map[string]string) *Error
- func Errf(code int, e Enum, format string, a ...interface{}) *Error
- func Errorf(code int, reason, format string, a ...interface{}) *Error
- func New(code int, reason, message string) *Error
- func NewWithMetadata(code int, reason, message string, md map[string]string) *Error
- func Newf(code int, reason, format string, a ...interface{}) *Error
- func WithStack(e *errors.Error) *Error
- func Wrap(e *errors.Error, eSlice ...error) *Error
- func (e *Error) Cause() error
- func (e *Error) Error() string
- func (e *Error) Format(s fmt.State, verb rune)
- func (e *Error) GetCode() int32
- func (e *Error) GetMessage() string
- func (e *Error) GetMetadata() map[string]string
- func (e *Error) GetReason() string
- func (e *Error) Message() string
- func (e *Error) StackTrace() StackTrace
- type Frame
- type StackTrace
Examples ¶
Constants ¶
const EnumNumberKey = "enum_number"
Variables ¶
var ( ERROR_name = map[int32]string{ 0: "UNKNOWN", 10001: "REQUEST_FAILED", 10002: "RECORD_NOT_FOUND", 10003: "RECORD_ALREADY_EXISTS", 10004: "NETWORK_ERROR", 10005: "NETWORK_TIMEOUT", 10006: "CONNECTION_ERROR", 10007: "UNINITIALIZED", 10008: "UNIMPLEMENTED", 10009: "INVALID_PARAMETER", 10010: "REQUEST_NOT_SUPPORT", 10011: "INTERNAL_ERROR", 10012: "PANIC", 10013: "FATAL", 11001: "DB", 11002: "MYSQL", 11003: "MONGO", 11004: "CACHE", 11005: "REDIS", 12001: "MQ", 12002: "QUEUE", 12003: "RABBIT_MQ", 12004: "KAFKA", 13002: "THIRD_PARTY_SERVICE_INVALID_CODE", 13001: "THIRD_PARTY_SERVICE_INTERNAL_ERROR", 100: "CONTINUE", 101: "SWITCHING_PROTOCOLS", 102: "PROCESSING", 103: "EARLY_HINTS", 200: "OK", 201: "CREATED", 202: "ACCEPTED", 203: "NON_AUTHORITATIVE_INFO", 204: "NO_CONTENT", 205: "RESET_CONTENT", 206: "PARTIAL_CONTENT", 207: "MULTI_STATUS", 208: "ALREADY_REPORTED", 226: "I_M_USED", 300: "MULTIPLE_CHOICES", 301: "MOVED_PERMANENTLY", 302: "FOUND", 303: "SEE_OTHER", 304: "NOT_MODIFIED", 305: "USE_PROXY", 306: "EMPTY306", 307: "TEMPORARY_REDIRECT", 308: "PERMANENT_REDIRECT", 400: "BAD_REQUEST", 401: "UNAUTHORIZED", 402: "PAYMENT_REQUIRED", 403: "FORBIDDEN", 404: "NOT_FOUND", 405: "METHOD_NOT_ALLOWED", 406: "NOT_ACCEPTABLE", 407: "PROXY_AUTH_REQUIRED", 408: "REQUEST_TIMEOUT", 409: "CONFLICT", 410: "GONE", 411: "LENGTH_REQUIRED", 412: "PRECONDITION_FAILED", 413: "REQUEST_ENTITY_TOO_LARGE", 414: "REQUEST_URI_TOO_LONG", 415: "UNSUPPORTED_MEDIA_TYPE", 416: "REQUESTED_RANGE_NOT_SATISFIABLE", 417: "EXPECTATION_FAILED", 418: "TEAPOT", 421: "MISDIRECTED_REQUEST", 422: "UNPROCESSABLE_ENTITY", 423: "LOCKED", 424: "FAILED_DEPENDENCY", 425: "TOO_EARLY", 426: "UPGRADE_REQUIRED", 428: "PRECONDITION_REQUIRED", 429: "TOO_MANY_REQUESTS", 431: "REQUEST_HEADER_FIELDS_TOO_LARGE", 451: "UNAVAILABLE_FOR_LEGAL_REASONS", 499: "CLIENT_CLOSE", 500: "INTERNAL_SERVER", 501: "NOT_IMPLEMENTED", 502: "BAD_GATEWAY", 503: "SERVICE_UNAVAILABLE", 504: "GATEWAY_TIMEOUT", 505: "HTTP_VERSION_NOT_SUPPORTED", 506: "VARIANT_ALSO_NEGOTIATES", 507: "INSUFFICIENT_STORAGE", 508: "LOOP_DETECTED", 510: "NOT_EXTENDED", 511: "NETWORK_AUTHENTICATION_REQUIRED", } ERROR_value = map[string]int32{ "UNKNOWN": 0, "REQUEST_FAILED": 10001, "RECORD_NOT_FOUND": 10002, "RECORD_ALREADY_EXISTS": 10003, "NETWORK_ERROR": 10004, "NETWORK_TIMEOUT": 10005, "CONNECTION_ERROR": 10006, "UNINITIALIZED": 10007, "UNIMPLEMENTED": 10008, "INVALID_PARAMETER": 10009, "REQUEST_NOT_SUPPORT": 10010, "INTERNAL_ERROR": 10011, "PANIC": 10012, "FATAL": 10013, "DB": 11001, "MYSQL": 11002, "MONGO": 11003, "CACHE": 11004, "REDIS": 11005, "MQ": 12001, "QUEUE": 12002, "RABBIT_MQ": 12003, "KAFKA": 12004, "THIRD_PARTY_SERVICE_INVALID_CODE": 13002, "THIRD_PARTY_SERVICE_INTERNAL_ERROR": 13001, "CONTINUE": 100, "SWITCHING_PROTOCOLS": 101, "PROCESSING": 102, "EARLY_HINTS": 103, "OK": 200, "CREATED": 201, "ACCEPTED": 202, "NON_AUTHORITATIVE_INFO": 203, "NO_CONTENT": 204, "RESET_CONTENT": 205, "PARTIAL_CONTENT": 206, "MULTI_STATUS": 207, "ALREADY_REPORTED": 208, "I_M_USED": 226, "MULTIPLE_CHOICES": 300, "MOVED_PERMANENTLY": 301, "FOUND": 302, "SEE_OTHER": 303, "NOT_MODIFIED": 304, "USE_PROXY": 305, "EMPTY306": 306, "TEMPORARY_REDIRECT": 307, "PERMANENT_REDIRECT": 308, "BAD_REQUEST": 400, "UNAUTHORIZED": 401, "PAYMENT_REQUIRED": 402, "FORBIDDEN": 403, "NOT_FOUND": 404, "METHOD_NOT_ALLOWED": 405, "NOT_ACCEPTABLE": 406, "PROXY_AUTH_REQUIRED": 407, "REQUEST_TIMEOUT": 408, "CONFLICT": 409, "GONE": 410, "LENGTH_REQUIRED": 411, "PRECONDITION_FAILED": 412, "REQUEST_ENTITY_TOO_LARGE": 413, "REQUEST_URI_TOO_LONG": 414, "UNSUPPORTED_MEDIA_TYPE": 415, "REQUESTED_RANGE_NOT_SATISFIABLE": 416, "EXPECTATION_FAILED": 417, "TEAPOT": 418, "MISDIRECTED_REQUEST": 421, "UNPROCESSABLE_ENTITY": 422, "LOCKED": 423, "FAILED_DEPENDENCY": 424, "TOO_EARLY": 425, "UPGRADE_REQUIRED": 426, "PRECONDITION_REQUIRED": 428, "TOO_MANY_REQUESTS": 429, "REQUEST_HEADER_FIELDS_TOO_LARGE": 431, "UNAVAILABLE_FOR_LEGAL_REASONS": 451, "CLIENT_CLOSE": 499, "INTERNAL_SERVER": 500, "NOT_IMPLEMENTED": 501, "BAD_GATEWAY": 502, "SERVICE_UNAVAILABLE": 503, "GATEWAY_TIMEOUT": 504, "HTTP_VERSION_NOT_SUPPORTED": 505, "VARIANT_ALSO_NEGOTIATES": 506, "INSUFFICIENT_STORAGE": 507, "LOOP_DETECTED": 508, "NOT_EXTENDED": 510, "NETWORK_AUTHENTICATION_REQUIRED": 511, } )
Enum value maps for ERROR.
var (
// DefaultStackTracerDepth 错误追踪最深层数
DefaultStackTracerDepth = 10
)
var File_kratos_error_error_kit_proto protoreflect.FileDescriptor
Functions ¶
func BadRequest ¶
BadRequest mapped to a 400 response.
func BadRequestWithMetadata ¶
BadRequestWithMetadata mapped to a 400 response.
func CallerWithSkip ¶
CallerWithSkip 序列化调用者:file:line
func Cause ¶
Cause returns the underlying cause of the error
Example ¶
err := New(http.StatusNotFound, "StatusNotFound", "StatusNotFound") fmt.Println(Cause(err))
Output:
func ClientClosed ¶
ClientClosed mapped to a HTTP 499 response.
func ClientClosedWithMetadata ¶
ClientClosedWithMetadata mapped to a HTTP 499 response.
func Code ¶
Code returns the http code for a error.
Example ¶
err := New(http.StatusNotFound, "StatusNotFound", "StatusNotFound") fmt.Println(Code(err))
Output:
func ConflictWithMetadata ¶
ConflictWithMetadata mapped to a 409 response.
func ErrorAccepted ¶
func ErrorAlreadyReported ¶
func ErrorBadGateway ¶
func ErrorBadRequest ¶
BAD_REQUEST Bad Request
func ErrorCache ¶
func ErrorClientClose ¶
func ErrorConflict ¶
func ErrorConnectionError ¶
func ErrorContinue ¶
CONTINUE Continue
func ErrorCreated ¶
func ErrorEarlyHints ¶
func ErrorEmpty306 ¶
func ErrorExpectationFailed ¶
func ErrorFailedDependency ¶
func ErrorFatal ¶
func ErrorForbidden ¶
func ErrorFound ¶
func ErrorGatewayTimeout ¶
func ErrorIMUsed ¶
func ErrorInternalError ¶
func ErrorInternalServer ¶
INTERNAL_SERVER Internal Server Error
func ErrorInvalidParameter ¶
func ErrorKafka ¶
func ErrorLengthRequired ¶
func ErrorLocked ¶
func ErrorLoopDetected ¶
func ErrorMethodNotAllowed ¶
func ErrorMisdirectedRequest ¶
func ErrorMongo ¶
func ErrorMovedPermanently ¶
func ErrorMultiStatus ¶
func ErrorMultipleChoices ¶
MULTIPLE_CHOICES MultipleChoices
func ErrorMysql ¶
func ErrorNetworkError ¶
func ErrorNetworkTimeout ¶
func ErrorNoContent ¶
func ErrorNotAcceptable ¶
func ErrorNotExtended ¶
func ErrorNotFound ¶
func ErrorNotImplemented ¶
func ErrorNotModified ¶
func ErrorPanic ¶
func ErrorPartialContent ¶
func ErrorPaymentRequired ¶
func ErrorPermanentRedirect ¶
func ErrorPreconditionFailed ¶
func ErrorProcessing ¶
func ErrorProxyAuthRequired ¶
func ErrorQueue ¶
func ErrorRabbitMq ¶
func ErrorRecordNotFound ¶
func ErrorRedis ¶
func ErrorRequestFailed ¶
func ErrorRequestNotSupport ¶
func ErrorRequestTimeout ¶
func ErrorRequestUriTooLong ¶
func ErrorResetContent ¶
func ErrorSeeOther ¶
func ErrorServiceUnavailable ¶
func ErrorSwitchingProtocols ¶
func ErrorTeapot ¶
func ErrorTemporaryRedirect ¶
func ErrorThirdPartyServiceInternalError ¶
第三方服务错误
func ErrorThirdPartyServiceInvalidCode ¶
THIRD_PARTY_SERVICE_INVALID_CODE third party
func ErrorTooEarly ¶
func ErrorTooManyRequests ¶
func ErrorUnauthorized ¶
func ErrorUnimplemented ¶
func ErrorUninitialized ¶
func ErrorUpgradeRequired ¶
func ErrorUseProxy ¶
func ForbiddenWithMetadata ¶
ForbiddenWithMetadata mapped to a 403 response.
func FromError ¶
FromError try to convert an error to *errors.Error
Example ¶
err := New(http.StatusNotFound, "StatusNotFound", "StatusNotFound") cause := FromError(err) fmt.Println("error Code ", cause.Code) fmt.Println("error Reason ", cause.Reason) fmt.Println("error Message ", cause.Message) fmt.Println("error Metadata ", cause.Metadata)
Output:
func GatewayTimeout ¶
GatewayTimeout mapped to a HTTP 504 response.
func GatewayTimeoutWithMetadata ¶
GatewayTimeoutWithMetadata mapped to a HTTP 504 response.
func InternalServer ¶
InternalServer mapped to a 500 response.
func InternalServerWithMetadata ¶
InternalServerWithMetadata mapped to a 500 response.
func IsAccepted ¶
func IsAlreadyReported ¶
func IsBadGateway ¶
func IsClientClose ¶
func IsCode ¶
IsCode .
Example ¶
err := New(http.StatusNotFound, "StatusNotFound", "StatusNotFound") fmt.Println(IsCode(err, http.StatusNotFound))
Output:
func IsConflict ¶
func IsConnectionError ¶
func IsEarlyHints ¶
func IsEmpty306 ¶
func IsExpectationFailed ¶
func IsFailedDependency ¶
func IsForbidden ¶
func IsGatewayTimeout ¶
func IsInsufficientStorage ¶
func IsInternalError ¶
func IsInvalidParameter ¶
func IsLengthRequired ¶
func IsLoopDetected ¶
func IsMethodNotAllowed ¶
func IsMisdirectedRequest ¶
func IsMovedPermanently ¶
func IsMultiStatus ¶
func IsNetworkError ¶
func IsNetworkTimeout ¶
func IsNoContent ¶
func IsNonAuthoritativeInfo ¶
func IsNotAcceptable ¶
func IsNotExtended ¶
func IsNotFound ¶
func IsNotImplemented ¶
func IsNotModified ¶
func IsPartialContent ¶
func IsPaymentRequired ¶
func IsPermanentRedirect ¶
func IsPreconditionFailed ¶
func IsPreconditionRequired ¶
func IsProcessing ¶
func IsProxyAuthRequired ¶
func IsRabbitMq ¶
func IsReason ¶
IsReason .
Example ¶
err := New(http.StatusNotFound, "StatusNotFound", "StatusNotFound") fmt.Println(IsReason(err, "StatusNotFound"))
Output:
func IsRecordAlreadyExists ¶
func IsRecordNotFound ¶
func IsRequestEntityTooLarge ¶
func IsRequestFailed ¶
func IsRequestNotSupport ¶
func IsRequestTimeout ¶
func IsRequestUriTooLong ¶
func IsResetContent ¶
func IsSeeOther ¶
func IsServiceUnavailable ¶
func IsSwitchingProtocols ¶
func IsTemporaryRedirect ¶
func IsThirdPartyServiceInternalError ¶
第三方服务错误
func IsThirdPartyServiceInvalidCode ¶
THIRD_PARTY_SERVICE_INVALID_CODE third party
func IsTooEarly ¶
func IsTooManyRequests ¶
func IsUnauthorized ¶
func IsUnimplemented ¶
func IsUninitialized ¶
func IsUnprocessableEntity ¶
func IsUnsupportedMediaType ¶
func IsUpgradeRequired ¶
func IsUseProxy ¶
func IsVariantAlsoNegotiates ¶
func NotFoundWithMetadata ¶
NotFoundWithMetadata mapped to a 404 response.
func NotImplemented ¶
NotImplemented mapped to a HTTP 501 response.
func NotImplementedWithMetadata ¶
NotImplementedWithMetadata mapped to a HTTP 501 response.
func Reason ¶
Reason returns the reason for a particular error.
Example ¶
err := New(http.StatusNotFound, "StatusNotFound", "StatusNotFound") fmt.Println(Reason(err))
Output:
func ServiceUnavailable ¶
ServiceUnavailable mapped to a HTTP 503 response.
func ServiceUnavailableWithMetadata ¶
ServiceUnavailableWithMetadata mapped to a HTTP 503 response.
func StatusOKWithMetadata ¶
StatusOKWithMetadata 200
func TooManyRequests ¶
TooManyRequests mapped to a 429 response.
func TooManyRequestsWithMetadata ¶
TooManyRequestsWithMetadata mapped to a 409 response.
func Unauthorized ¶
Unauthorized mapped to a 401 response.
func UnauthorizedWithMetadata ¶
UnauthorizedWithMetadata mapped to a 401 response.
func WrapWithEnumNumber ¶
WrapWithEnumNumber enum number
Types ¶
type ERROR ¶
type ERROR int32
ERROR .
const ( // UNKNOWN 常规 ERROR_UNKNOWN ERROR = 0 ERROR_REQUEST_FAILED ERROR = 10001 ERROR_RECORD_NOT_FOUND ERROR = 10002 ERROR_RECORD_ALREADY_EXISTS ERROR = 10003 ERROR_NETWORK_ERROR ERROR = 10004 ERROR_NETWORK_TIMEOUT ERROR = 10005 ERROR_CONNECTION_ERROR ERROR = 10006 ERROR_UNINITIALIZED ERROR = 10007 ERROR_UNIMPLEMENTED ERROR = 10008 ERROR_INVALID_PARAMETER ERROR = 10009 ERROR_REQUEST_NOT_SUPPORT ERROR = 10010 ERROR_INTERNAL_ERROR ERROR = 10011 ERROR_PANIC ERROR = 10012 ERROR_FATAL ERROR = 10013 // DB database ERROR_DB ERROR = 11001 ERROR_MYSQL ERROR = 11002 ERROR_MONGO ERROR = 11003 ERROR_CACHE ERROR = 11004 ERROR_REDIS ERROR = 11005 // MQ message queue ERROR_MQ ERROR = 12001 ERROR_QUEUE ERROR = 12002 ERROR_RABBIT_MQ ERROR = 12003 ERROR_KAFKA ERROR = 12004 // THIRD_PARTY_SERVICE_INVALID_CODE third party ERROR_THIRD_PARTY_SERVICE_INVALID_CODE ERROR = 13002 // 第三方服务响应结果有误 ERROR_THIRD_PARTY_SERVICE_INTERNAL_ERROR ERROR = 13001 // 第三方服务错误 // CONTINUE Continue ERROR_CONTINUE ERROR = 100 ERROR_SWITCHING_PROTOCOLS ERROR = 101 ERROR_PROCESSING ERROR = 102 ERROR_EARLY_HINTS ERROR = 103 // OK OK ERROR_OK ERROR = 200 ERROR_CREATED ERROR = 201 ERROR_ACCEPTED ERROR = 202 ERROR_NON_AUTHORITATIVE_INFO ERROR = 203 ERROR_NO_CONTENT ERROR = 204 ERROR_RESET_CONTENT ERROR = 205 ERROR_PARTIAL_CONTENT ERROR = 206 ERROR_MULTI_STATUS ERROR = 207 ERROR_ALREADY_REPORTED ERROR = 208 ERROR_I_M_USED ERROR = 226 // MULTIPLE_CHOICES MultipleChoices ERROR_MULTIPLE_CHOICES ERROR = 300 ERROR_MOVED_PERMANENTLY ERROR = 301 ERROR_FOUND ERROR = 302 ERROR_SEE_OTHER ERROR = 303 ERROR_NOT_MODIFIED ERROR = 304 ERROR_USE_PROXY ERROR = 305 ERROR_EMPTY306 ERROR = 306 ERROR_TEMPORARY_REDIRECT ERROR = 307 ERROR_PERMANENT_REDIRECT ERROR = 308 // BAD_REQUEST Bad Request ERROR_BAD_REQUEST ERROR = 400 ERROR_UNAUTHORIZED ERROR = 401 ERROR_PAYMENT_REQUIRED ERROR = 402 ERROR_FORBIDDEN ERROR = 403 ERROR_NOT_FOUND ERROR = 404 ERROR_METHOD_NOT_ALLOWED ERROR = 405 ERROR_NOT_ACCEPTABLE ERROR = 406 ERROR_PROXY_AUTH_REQUIRED ERROR = 407 ERROR_REQUEST_TIMEOUT ERROR = 408 ERROR_CONFLICT ERROR = 409 ERROR_GONE ERROR = 410 ERROR_LENGTH_REQUIRED ERROR = 411 ERROR_PRECONDITION_FAILED ERROR = 412 ERROR_REQUEST_ENTITY_TOO_LARGE ERROR = 413 ERROR_REQUEST_URI_TOO_LONG ERROR = 414 ERROR_UNSUPPORTED_MEDIA_TYPE ERROR = 415 ERROR_REQUESTED_RANGE_NOT_SATISFIABLE ERROR = 416 ERROR_EXPECTATION_FAILED ERROR = 417 ERROR_TEAPOT ERROR = 418 ERROR_MISDIRECTED_REQUEST ERROR = 421 ERROR_UNPROCESSABLE_ENTITY ERROR = 422 ERROR_LOCKED ERROR = 423 ERROR_FAILED_DEPENDENCY ERROR = 424 ERROR_TOO_EARLY ERROR = 425 ERROR_UPGRADE_REQUIRED ERROR = 426 ERROR_PRECONDITION_REQUIRED ERROR = 428 ERROR_TOO_MANY_REQUESTS ERROR = 429 ERROR_REQUEST_HEADER_FIELDS_TOO_LARGE ERROR = 431 ERROR_UNAVAILABLE_FOR_LEGAL_REASONS ERROR = 451 ERROR_CLIENT_CLOSE ERROR = 499 // INTERNAL_SERVER Internal Server Error ERROR_INTERNAL_SERVER ERROR = 500 ERROR_NOT_IMPLEMENTED ERROR = 501 ERROR_BAD_GATEWAY ERROR = 502 ERROR_SERVICE_UNAVAILABLE ERROR = 503 ERROR_GATEWAY_TIMEOUT ERROR = 504 ERROR_HTTP_VERSION_NOT_SUPPORTED ERROR = 505 ERROR_VARIANT_ALSO_NEGOTIATES ERROR = 506 ERROR_INSUFFICIENT_STORAGE ERROR = 507 ERROR_LOOP_DETECTED ERROR = 508 ERROR_NOT_EXTENDED ERROR = 510 ERROR_NETWORK_AUTHENTICATION_REQUIRED ERROR = 511 )
func (ERROR) Descriptor ¶
func (ERROR) Descriptor() protoreflect.EnumDescriptor
func (ERROR) EnumDescriptor
deprecated
func (ERROR) Number ¶
func (x ERROR) Number() protoreflect.EnumNumber
func (ERROR) Type ¶
func (ERROR) Type() protoreflect.EnumType
type Enum ¶
type Enum interface { String() string Number() protoreflect.EnumNumber }
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error ...
func ErrWithMetadata ¶
ErrWithMetadata ...
func New ¶
New ...
Example ¶
err := New(http.StatusNotFound, "StatusNotFound", "StatusNotFound") fmt.Printf("%+v\n", err)
Output:
func NewWithMetadata ¶
NewWithMetadata ...
func (*Error) GetMessage ¶
func (*Error) GetMetadata ¶
type Frame ¶
type Frame uintptr
Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.
func (Frame) Format ¶
Format formats the frame according to the fmt.Formatter interface.
%s source file %d source line %n function name %v equivalent to %s:%d
Format accepts flags that alter the printing of some verbs, as follows:
%+s function name and path of source file relative to the compile time GOPATH separated by \n\t (<funcname>\n\t<path>) %+v equivalent to %+s:%d
func (Frame) MarshalText ¶
MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.
type StackTrace ¶
type StackTrace []Frame
StackTrace is stack of Frames from innermost (newest) to outermost (oldest).
func (StackTrace) Format ¶
func (st StackTrace) Format(s fmt.State, verb rune)
Format formats the stack of Frames according to the fmt.Formatter interface.
%s lists source files for each Frame in the stack %v lists the source file and line number for each Frame in the stack
Format accepts flags that alter the printing of some verbs, as follows:
%+v Prints filename, function, and line number for each Frame in the stack.