Documentation
¶
Index ¶
- type Context
- type ContextKey
- type Error
- func NewError(code string, errType ErrorType, severity ErrorSeverity, msg string) *Error
- func NewErrorCancelled(code string, msg string) *Error
- func NewErrorConflict(code string, msg string) *Error
- func NewErrorInternal(code string, msg string) *Error
- func NewErrorNotFound(code string, msg string) *Error
- func NewErrorPermission(code string, msg string) *Error
- func NewErrorTimeout(code string, msg string) *Error
- func NewErrorUnauthorised(code string, msg string) *Error
- func NewErrorValidation(code string, msg string) *Error
- func (e *Error) AddValidationError(err FieldValidationError)
- func (e Error) Cause() error
- func (e Error) Code() string
- func (e Error) Detail() string
- func (e Error) Error() string
- func (e *Error) SetDetail(detail string) *Error
- func (e *Error) SetSeverity(severity ErrorSeverity) *Error
- func (e Error) Severity() ErrorSeverity
- func (e Error) Type() ErrorType
- func (e Error) ValidationErrors() FieldValidationErrors
- func (e *Error) Wrap(err error) *Error
- type ErrorSeverity
- type ErrorType
- type FieldValidationError
- type FieldValidationErrors
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
Context carries the context of the current execution.
func FromContext ¶
FromContext returns a new Context from a context.Context
func (*Context) SetTenantID ¶
SetTenantID sets the user id
func (*Context) SetTraceID ¶
SetTraceID sets the trace id
type ContextKey ¶
type ContextKey string
const ( TraceIDKey ContextKey = "trace_id" UserIDKey ContextKey = "user_id" TenantIDKey ContextKey = "tenant_id" )
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Application Error
func NewError ¶
func NewError(code string, errType ErrorType, severity ErrorSeverity, msg string) *Error
NewError creates a application new error
func NewErrorCancelled ¶
NewErrorCancelled creates an error of type cancelled
func NewErrorConflict ¶
NewErrorConflict creates an error of type conflict
func NewErrorInternal ¶
NewErrorInternal creates an error of type internal
func NewErrorNotFound ¶
NewErrorNotFound creates an error of type not found
func NewErrorPermission ¶
NewErrorPermission creates an error of type permission
func NewErrorTimeout ¶
NewErrorTimeout creates an error of type timeout
func NewErrorUnauthorised ¶
NewErrorUnauthorised creates an error of type unauthorised
func NewErrorValidation ¶
NewErrorValidation creates an error of type validation
func (*Error) AddValidationError ¶
func (e *Error) AddValidationError(err FieldValidationError)
Add validation errors
func (*Error) SetSeverity ¶
func (e *Error) SetSeverity(severity ErrorSeverity) *Error
Set the original error severity
func (Error) ValidationErrors ¶
func (e Error) ValidationErrors() FieldValidationErrors
Get validation errors
type ErrorSeverity ¶
type ErrorSeverity string
Error Severity
const ( // ErrorSeverityLow - expected errors like validation ErrorSeverityLow ErrorSeverity = "low" // ErrorSeverityMedium - errors that are not urgent to look into. ErrorSeverityMedium ErrorSeverity = "medium" // ErrorSeverityHigh - errors that shouldn't happen but the system is still working. ErrorSeverityHigh ErrorSeverity = "high" // ErrorSeverityCritical - errors that impact the system from working. ErrorSeverityCritical ErrorSeverity = "critical" )
type ErrorType ¶
type ErrorType string
ErrorType defines the type of an error
const ( // ErrorInternal error ErrorInternal ErrorType = "internal" // ErrorNotFound error ErrorNotFound ErrorType = "not_found" // ErrorValidation error ErrorValidation ErrorType = "validation" // ErrorPermission error ErrorPermission ErrorType = "permission" ErrorUnauthorised ErrorType = "unauthorised" // ErrorConflict error ErrorConflict ErrorType = "conflict" // ErrorTimeout error ErrorTimeout ErrorType = "timeout" // ErrorCancelled error ErrorCancelled ErrorType = "cancelled" )
type FieldValidationError ¶
type FieldValidationError struct {
// contains filtered or unexported fields
}
func NewFieldValidationError ¶
func NewFieldValidationError(identifier string, messages ...string) FieldValidationError
New Validation Error