Documentation ¶
Overview ¶
Package errors provides a way to return detailed information for an RPC request error. The error is normally JSON encoded.
Index ¶
- Variables
- func BadGateway(id, format string, args ...interface{}) error
- func BadRequest(id, format string, args ...interface{}) error
- func CodeIn(err interface{}, codes ...int32) bool
- func Conflict(id, format string, args ...interface{}) error
- func Equal(err1 error, err2 error) bool
- func Forbidden(id, format string, args ...interface{}) error
- func GatewayTimeout(id, format string, args ...interface{}) error
- func InternalServerError(id, format string, args ...interface{}) error
- func MethodNotAllowed(id, format string, args ...interface{}) error
- func New(id, detail string, code int32) error
- func NotFound(id, format string, args ...interface{}) error
- func NotImplemented(id, format string, args ...interface{}) error
- func ServiceUnavailable(id, format string, args ...interface{}) error
- func Timeout(id, format string, args ...interface{}) error
- func Unauthorized(id, format string, args ...interface{}) error
- type Error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrBadRequest returns then requests contains invalid data ErrBadRequest = &Error{Code: 400} ErrUnauthorized = &Error{Code: 401} // ErrForbidden returns then user have not access the resource ErrForbidden = &Error{Code: 403} // ErrNotFound returns then user specify invalid endpoint ErrNotFound = &Error{Code: 404} // ErrMethodNotAllowed returns then user try to get invalid method ErrMethodNotAllowed = &Error{Code: 405} // ErrTimeout returns then timeout exceeded ErrTimeout = &Error{Code: 408} // ErrConflict returns then request create duplicate resource ErrConflict = &Error{Code: 409} // ErrInternalServerError returns then server cant process request because of internal error ErrInternalServerError = &Error{Code: 500} // ErNotImplemented returns then server does not have desired endpoint method ErNotImplemented = &Error{Code: 501} // ErrBadGateway returns then server cant process request ErrBadGateway = &Error{Code: 502} ErrServiceUnavailable = &Error{Code: 503} // ErrGatewayTimeout returns then server have long time to process request ErrGatewayTimeout = &Error{Code: 504} )
Functions ¶
func BadGateway ¶
BadGateway generates a 502 error
func BadRequest ¶
BadRequest generates a 400 error.
func GatewayTimeout ¶
GatewayTimeout generates a 504 error
func InternalServerError ¶
InternalServerError generates a 500 error.
func MethodNotAllowed ¶
MethodNotAllowed generates a 405 error.
func NotImplemented ¶
NotImplemented generates a 501 error
func ServiceUnavailable ¶
ServiceUnavailable generates a 503 error
func Unauthorized ¶
Unauthorized generates a 401 error.
Types ¶
type Error ¶
type Error struct { // ID holds error id or service, usually someting like my_service or id ID string // Detail holds some useful details about error Detail string // Status usually holds text of http status Status string // Code holds error code Code int32 }
Error type
func Parse ¶
Parse tries to parse a JSON string into an error. If that fails, it will set the given string as the error detail.
func (*Error) MarshalJSON ¶ added in v3.8.16
MarshalJSON returns error data
func (*Error) UnmarshalJSON ¶ added in v3.8.16
UnmarshalJSON set error data
Click to show internal directories.
Click to hide internal directories.