Documentation ¶
Index ¶
- Constants
- func LastResortHandler(loc string)
- func LastResortHandlerWithContext(ctx context.Context, loc string)
- func NewClientError(err string) error
- func NewSystemError(ctx context.Context, err string) error
- func NewValidationError(err string) error
- func SetupEventing()
- func WriteDeveloperEvent(ctx context.Context, msg string)
- type Error
Constants ¶
const ( //2xx StatusOK = http.StatusOK //4xx StatusBadRequest = http.StatusBadRequest StatusPaymentRequired = http.StatusPaymentRequired StatusForbidden = http.StatusForbidden StatusNotFound = http.StatusNotFound //5xx StatusInternalServerError = http.StatusInternalServerError StatusNotImplemented = http.StatusNotImplemented )
Variables ¶
This section is empty.
Functions ¶
func LastResortHandler ¶
func LastResortHandler(loc string)
LastResortHandler - Setup at start of program to capture panics not solved elsewhere to enable logging prior to program close down
func LastResortHandlerWithContext ¶
LastResortHandlerWithContext - Setup at start of program to capture panics not solved elsewhere to enable logging prior to program close down
func NewClientError ¶
NewClientError - returns a default BadRequest denoting a client user error
func NewSystemError ¶
NewSystemError - returns a default InternalServerError denoting an implementation issue
func NewValidationError ¶
NewValidationError - returns a default StatusOK error denoting a user validation error
func SetupEventing ¶
func SetupEventing()
SetupEventing - Configures your eventing if enabled via env variable: ERROR_EVENTING = true
func WriteDeveloperEvent ¶
WriteDeveloperEvent - Sends message to sentry to enable a developer to pick up and fix a known issue where auto-fix is not yet known To be used when client should not receive error however developer MUST fix it to restore full client functionality
Types ¶
type Error ¶
type Error struct { ErrorType int DeveloperMessage string UserMessage string ErrorCode string MoreInfo string }
Error contains - - errorType - from the const list, the type of error this represents. The New constructors set reasonable default status that can be replaced if appropriate. - developerMessage - message that may help the developer use the API correctly
- userMessage - message for the end user display
- errorCode - error to report to support or standardized user error code as applicable
- moreInfo - link to documentation with more info
- If eventing is enabled, event will be generated upon creation. For now, have only setup for system errors to event. For example, validation errors or client errors will not event. Can change to config in the future
Future TODO:
- add correlation id into errorCode or moreInfo when reporting