Documentation ¶
Index ¶
- func HasDBError(dbErrors []error) bool
- func IsDBRecordNotFoundError(dbErrors []error) bool
- func NewErrorFromDBErrors(prefix string, dbErrors []error) error
- type APIServerContext
- func (ctx *APIServerContext) Criticalf(format string, params ...interface{})
- func (ctx *APIServerContext) Debugf(format string, params ...interface{})
- func (ctx *APIServerContext) Errorf(format string, params ...interface{})
- func (ctx *APIServerContext) Infof(format string, params ...interface{})
- func (ctx *APIServerContext) SetRequestID(requestID uint64) context.Context
- func (ctx *APIServerContext) Tracef(format string, params ...interface{})
- func (ctx *APIServerContext) Warnf(format string, params ...interface{})
- type HandlerError
- func NewHandlerError(code int, message string) *HandlerError
- func NewHandlerErrorFromDBErrors(prefix string, dbErrors []error) *HandlerError
- func NewHandlerErrorWithCustomClientMessage(code int, message, clientMessage string) *HandlerError
- func NewInternalServerHandlerError(message string) *HandlerError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasDBError ¶
HasDBError returns true if the given dbErrors contain any errors that aren't RecordNotFound
func IsDBRecordNotFoundError ¶
IsDBRecordNotFoundError returns true if the given dbErrors contains only a RecordNotFound error
func NewErrorFromDBErrors ¶
NewErrorFromDBErrors takes a slice of database errors and a prefix, and returns an error with all of the database errors formatted to one string with the given prefix
Types ¶
type APIServerContext ¶
APIServerContext is a context.Context wrapper that enables custom logs with request ID.
func ToAPIServerContext ¶
func ToAPIServerContext(ctx context.Context) *APIServerContext
ToAPIServerContext takes a context.Context instance and converts it to *ApiServerContext.
func (*APIServerContext) Criticalf ¶
func (ctx *APIServerContext) Criticalf(format string, params ...interface{})
Criticalf writes a customized formatted context related log with log level 'Critical'.
func (*APIServerContext) Debugf ¶
func (ctx *APIServerContext) Debugf(format string, params ...interface{})
Debugf writes a customized formatted context related log with log level 'Debug'.
func (*APIServerContext) Errorf ¶
func (ctx *APIServerContext) Errorf(format string, params ...interface{})
Errorf writes a customized formatted context related log with log level 'Error'.
func (*APIServerContext) Infof ¶
func (ctx *APIServerContext) Infof(format string, params ...interface{})
Infof writes a customized formatted context related log with log level 'Info'.
func (*APIServerContext) SetRequestID ¶
func (ctx *APIServerContext) SetRequestID(requestID uint64) context.Context
SetRequestID associates a request ID for the context.
func (*APIServerContext) Tracef ¶
func (ctx *APIServerContext) Tracef(format string, params ...interface{})
Tracef writes a customized formatted context related log with log level 'Trace'.
func (*APIServerContext) Warnf ¶
func (ctx *APIServerContext) Warnf(format string, params ...interface{})
Warnf writes a customized formatted context related log with log level 'Warn'.
type HandlerError ¶
HandlerError is an error returned from a rest route handler or a middleware.
func NewHandlerError ¶
func NewHandlerError(code int, message string) *HandlerError
NewHandlerError returns a HandlerError with the given code and message.
func NewHandlerErrorFromDBErrors ¶
func NewHandlerErrorFromDBErrors(prefix string, dbErrors []error) *HandlerError
NewHandlerErrorFromDBErrors takes a slice of database errors and a prefix, and returns an HandlerError with error code http.StatusInternalServerError with all of the database errors formatted to one string with the given prefix
func NewHandlerErrorWithCustomClientMessage ¶
func NewHandlerErrorWithCustomClientMessage(code int, message, clientMessage string) *HandlerError
NewHandlerErrorWithCustomClientMessage returns a HandlerError with the given code, message and client error message.
func NewInternalServerHandlerError ¶
func NewInternalServerHandlerError(message string) *HandlerError
NewInternalServerHandlerError returns a HandlerError with the given message, and the http.StatusInternalServerError status text as client message.
func (*HandlerError) Error ¶
func (hErr *HandlerError) Error() string