Documentation ¶
Index ¶
- Variables
- func Error2code(err error) int
- func ErrorEncoder(ctx context.Context, err error, w http.ResponseWriter)
- func New(err error, message string) error
- func NewErrorHandler() transport.ErrorHandler
- func NewHTTP(err error, code int, message string) error
- func Wrap(err error, message string) error
- type Error
- func (e Error) EditCause(err error) *Error
- func (e Error) EditCode(code string) *Error
- func (e Error) EditMessage(msg string) *Error
- func (e Error) EditStatusCode(statusCode int) *Error
- func (e *Error) Error() string
- func (e *Error) GetCause() error
- func (e *Error) GetMessage() string
- func (e *Error) GetStatusCode() int
- func (e *Error) ShowStack()
- type Interface
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrTokenInvalid is raised when token is invalid ErrTokenInvalid = errors.New("invalid token") // ErrTokenCheck is raised when check validity token failed ErrTokenCheck = errors.New("check validity token failed") // ErrTokenNotFound is raise when HTTP header does not contain Authorization ErrTokenNotFound = errors.New("authorization not found in http header") // ErrUnAuthorized is raised by check token on kratos with a non authorized token ErrUnAuthorized = errors.New("401 Unauthorized") // ErrMethod is raised when a internal call failed ErrMethod = errors.New("resource can't be empty") ErrServiceUnavailable = errors.New("service unavailable") )
Functions ¶
func Error2code ¶
Error2code return the http code according the Error code field or try to deduce it from the error itself
func ErrorEncoder ¶
func ErrorEncoder(ctx context.Context, err error, w http.ResponseWriter)
ErrorEncoder writes the error into http.ResponseWriter
func NewErrorHandler ¶
func NewErrorHandler() transport.ErrorHandler
NewErrorHandler returns an instance of transport.ErrorHandler
Types ¶
type Error ¶
type Error struct { // Cause original error Cause error `json:"-"` // StatusCode for http response code StatusCode int `json:"-"` // Code is the string convention from https://www.notion.so/w6d/Project-Spec-d1e49d91046b4b61952ecfc135983faf Code string `json:"code"` // Message from this error Message string `json:"message"` }
Error ...
func (Error) EditMessage ¶
EditMessage returns Error by updating message
func (Error) EditStatusCode ¶
EditStatusCode returns Error by updating status code
func (*Error) GetMessage ¶
GetMessage returns the message from Error
func (*Error) GetStatusCode ¶
GetStatusCode returns the http status code from Error
type Interface ¶
type Interface interface { // Error type representing an error condition, with the nil value representing no error. Error() string // GetCause type representing an error condition, with the nil value representing no error. GetCause() error // GetMessage returns the Message GetMessage() string // GetStatusCode returns http status code. GetStatusCode() int // ShowStack prints the stack if exist ShowStack() // EditCause field from Error struct then return it EditCause(error) *Error // EditMessage field from Error struct then return it EditMessage(string) *Error // EditCode field from Error struct then return it EditCode(string) *Error // EditStatusCode field from Error struct then return it EditStatusCode(int) *Error }
Interface of errorx
Click to show internal directories.
Click to hide internal directories.