Documentation ¶
Index ¶
- Variables
- func As(err error, target interface{}) bool
- func Cause(target error) error
- func ErrorResponse(ctx context.Context, err error, w http.ResponseWriter)
- func Is(err error, target error) bool
- func WithMessage(err error, message string) error
- func WithMessagef(err error, format string, args ...interface{}) error
- func Wrap(err error, msg string) error
- func Wrapf(err error, format string, args ...interface{}) error
- type Detail
- type DetailData
- type Exception
- type LoggerErrorHandle
- type View
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidInput = &Exception{Code: 400001, Message: "One of the request inputs is not valid.", Status: http.StatusBadRequest, GRPCCode: codes.InvalidArgument} ErrInvalidHeaderValue = &Exception{Code: 400003, Message: "The value provided for one of the HTTP headers was not in the correct format.", Status: http.StatusBadRequest, GRPCCode: codes.InvalidArgument} ErrForbidden = &Exception{Code: 403001, Message: "Forbidden.", Status: http.StatusForbidden, GRPCCode: codes.PermissionDenied} ErrPageNotFound = &Exception{Code: 404001, Message: "Page not found.", Status: http.StatusNotFound, GRPCCode: codes.NotFound} ErrResourceNotFound = &Exception{Code: 404002, Message: "The specified resource does not exist.", Status: http.StatusNotFound} ErrConflict = &Exception{Code: 409001, Message: "The request conflict.", Status: http.StatusConflict, GRPCCode: codes.AlreadyExists} ErrTooManyRequests = &Exception{Code: 429001, Message: "Too Many Requests", Status: http.StatusTooManyRequests, GRPCCode: codes.PermissionDenied} ErrInternal = &Exception{Code: 500001, Message: "Serve occur error.", Status: http.StatusInternalServerError, GRPCCode: codes.Internal} )
Functions ¶
func ErrorResponse ¶
func ErrorResponse(ctx context.Context, err error, w http.ResponseWriter)
ErrorResponse error response for go-kit
func WithMessage ¶
WithMessage annotates err with a new message. If err is nil, WithMessage returns nil.
func WithMessagef ¶
WithMessagef annotates err with the format specifier. If err is nil, WithMessagef returns nil.
Types ¶
type Exception ¶
type Exception struct { Code int `json:"code"` // error code for client define how to handle error Status int `json:"status"` // status is http status Message string `json:"message"` // error message for client GRPCCode codes.Code `json:"grpc_code"` // grpc error code Details []Detail `json:"details,omitempty"` // details is metadata for client debug }
Exception define custom error for tracmo cloud
func TryConvert ¶
func (*Exception) ToViewModel ¶
ToViewModel to restful view
func (*Exception) WithDetails ¶
WithDetails set detail error message
type LoggerErrorHandle ¶
type LoggerErrorHandle struct { }
func NewLoggingErrorHandle ¶
func NewLoggingErrorHandle() *LoggerErrorHandle
Click to show internal directories.
Click to hide internal directories.