# README
errno
业务域错误可以统一通过 proto 定义业务原因,然后通过 protoc 生成枚举定义和相关 helper functions。
在 errno 包中,错误模型主要跟 http 状态码一致,并且实现相关接口将 Error 与 GRPCStatus 互转。
errno 中的 Error 本身不携带堆栈信息,如果想要在 error 中携带堆栈信息,可以在业务代码中借助 github.com/pkg/errors 实现。 被 errors 库包装过的 Error 依然可以使用内置的 errno.IsXXX 等大错误类型判方法。
依赖项
安装新版 protoc-gen-go ,protoc-gen-go-grpc
# Functions
As finds the first error in err's chain that matches target, and if so, sets target to that error value and returns true.
BadRequest new BadRequest error that is mapped to a 400 response.
ClientClosed new ClientClosed error that is mapped to an HTTP 499 response.
Code returns the http code for a particular error.
Conflict new Conflict error that is mapped to a 409 response.
No description provided by the author
Errorf returns an error object for the code, message and error info.
No description provided by the author
Forbidden new Forbidden error that is mapped to a 403 response.
FromError try to convert an error to *Error.
GatewayTimeout new GatewayTimeout error that is mapped to an HTTP 504 response.
InternalServer new InternalServer error that is mapped to a 500 response.
Is reports whether any error in err's chain matches target.
IsBadRequest determines if err is an error which indicates a BadRequest error.
IsClientClosed determines if err is an error which indicates a ClientClosed error.
IsConflict determines if err is an error which indicates a Conflict error.
No description provided by the author
No description provided by the author
IsForbidden determines if err is an error which indicates a Forbidden error.
IsGatewayTimeout determines if err is an error which indicates a GatewayTimeout error.
IsInternalServer determines if err is an error which indicates an Internal error.
IsNotFound determines if err is an error which indicates an NotFound error.
IsNotImplemented determines if err is an error which indicates an NotImplemented error.
No description provided by the author
No description provided by the author
No description provided by the author
IsServiceUnavailable determines if err is an error which indicates an Unavailable error.
No description provided by the author
No description provided by the author
IsTooManyRequests determines if err is an error which indicates a TooManyRequests error.
IsUnauthorized determines if err is an error which indicates an Unauthorized error.
No description provided by the author
New returns an error object for the code, message.
Newf New(code fmt.Sprintf(format, a...)).
NotFound new NotFound error that is mapped to a 404 response.
NotImplemented new NotImplemented error that is mapped to a 500 response.
No description provided by the author
Reason returns the reason for a particular error.
No description provided by the author
No description provided by the author
ServiceUnavailable new ServiceUnavailable error that is mapped to an HTTP 503 response.
No description provided by the author
No description provided by the author
TooManyRequests new TooManyRequests error that is mapped to an HTTP 429 response.
Unauthorized new Unauthorized error that is mapped to a 401 response.
No description provided by the author
Unwrap returns the result of calling the Unwrap method on err, if err's type contains an Unwrap method returning error.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SupportPackageIsVersion1 this constant should not be referenced by any other code.
UnknownCode is unknown code for error info.
UnknownReason is unknown reason for error info.
# Variables
optional int32 code = 100001;.
optional int32 default_code = 100001;.
optional string message = 100002;.
No description provided by the author