Documentation ¶
Overview ¶
Package errors provides a way to return detailed information for an RPC request error. The error is normally JSON encoded.
Index ¶
- func BadRequest(id, format string, a ...interface{}) error
- func Conflict(id, format string, a ...interface{}) error
- func Err2GrpcCode(err error) codes.Code
- func Forbidden(id, format string, a ...interface{}) error
- func GrpcAcceptable(err error) bool
- func Http2GrpcCode(err *Error) codes.Code
- func InternalServerError(id, format string, a ...interface{}) error
- func MethodNotAllowed(id, format string, a ...interface{}) error
- func New(id, detail string, code int32) error
- func NotFound(id, format string, a ...interface{}) error
- func Timeout(id, format string, a ...interface{}) error
- func Unauthorized(id, format string, a ...interface{}) error
- func UnwrapIgnorableError(err string) (bool, string)
- func WrapIgnorableError(err error) error
- type Error
- type IgnorableError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
BadRequest generates a 400 error.
func Err2GrpcCode ¶
Err2GrpcCode converts a standard Go error into its canonical code. Note that this is only used to translate the error returned by the server applications.
func GrpcAcceptable ¶
func Http2GrpcCode ¶
func InternalServerError ¶
InternalServerError generates a 500 error.
func MethodNotAllowed ¶
MethodNotAllowed generates a 405 error.
func Unauthorized ¶
Unauthorized generates a 401 error.
func UnwrapIgnorableError ¶
UnwrapIgnorableError tries to parse a JSON string into an error. If that fails, it will set the given string as the error detail.
func WrapIgnorableError ¶
IgnoreError generates a -1 error.
Types ¶
type Error ¶
type Error struct { Id string `json:"id"` Code int32 `json:"code"` Detail string `json:"detail"` Status string `json:"status"` }
Error implements the error interface.
type IgnorableError ¶
func (*IgnorableError) Error ¶
func (e *IgnorableError) Error() string
Click to show internal directories.
Click to hide internal directories.