Documentation ¶
Index ¶
- Constants
- Variables
- func Code(e error) string
- func Details(e error) string
- func MapErrorData(e Error, obj interface{}) error
- func Message(e error) string
- func Original(e error) error
- type Error
- type ErrorBase
- func (e *ErrorBase) Code() string
- func (e *ErrorBase) Data() interface{}
- func (e *ErrorBase) Details() string
- func (e *ErrorBase) Error() string
- func (e *ErrorBase) Message() string
- func (e *ErrorBase) Original() error
- func (e *ErrorBase) SetData(data interface{})
- func (e *ErrorBase) SetDetails(details string)
- func (e *ErrorBase) SetMessage(message string)
- func (e *ErrorBase) SetOriginal(err error)
- type ErrorDefinitions
- type ErrorHolder
- type ErrorManager
- type ErrorManagerBase
- func (e *ErrorManagerBase) AddErrorDescriptions(m map[string]string)
- func (e *ErrorManagerBase) AddErrorProtocolCodes(m map[string]int)
- func (e *ErrorManagerBase) DefaultErrorProtocolCode() int
- func (e *ErrorManagerBase) ErrorDescription(code string, tr ...TranslationHandler) string
- func (e *ErrorManagerBase) ErrorProtocolCode(code string) int
- func (e *ErrorManagerBase) Init(defaultProtocolCode int)
- func (e *ErrorManagerBase) MakeGenericError(code string, tr ...TranslationHandler) Error
- func (e *ErrorManagerBase) SetDefaultErrorProtocolCode(code int)
- type ErrorManagerBaseHttp
- type ErrorsExtender
- type ErrorsExtenderBase
- func (e *ErrorsExtenderBase) AddErrors(errorDescriptions map[string]string, errorProtocolCodes ...map[string]int)
- func (e *ErrorsExtenderBase) AppendErrorExtender(extender ErrorsExtender)
- func (e *ErrorsExtenderBase) AttachToErrorManager(manager ErrorManager)
- func (e *ErrorsExtenderBase) Codes() map[string]int
- func (e *ErrorsExtenderBase) Descriptions() map[string]string
- func (e *ErrorsExtenderBase) Init(errorDescriptions map[string]string, errorProtocolCodes ...map[string]int)
- type ErrorsExtenderStub
- func (e *ErrorsExtenderStub) AddErrors(errorDescriptions map[string]string, errorProtocolCodes ...map[string]int)
- func (e *ErrorsExtenderStub) AppendErrorExtender(extender ErrorsExtender)
- func (e *ErrorsExtenderStub) AttachToErrorManager(manager ErrorManager)
- func (e *ErrorsExtenderStub) Codes() map[string]int
- func (e *ErrorsExtenderStub) Descriptions() map[string]string
- type TranslationHandler
Constants ¶
View Source
const ( ErrorCodeUnknown string = "unknown_error" ErrorCodeInternalServerError string = "internal_server_error" ErrorCodeFormat string = "invalid_format" ErrorCodeFieldValue string = "invalid_field_value" ErrorCodeValidation string = "validation_failed" ErrorCodeForbidden string = "forbidden" ErrorCodeNotFound string = "resource_not_found" ErrorCodeExternalServiceError string = "external_service_error" ErrorCodeUnsupported string = "operation_unsupported" ErrorCodeExpired string = "operation_expired" ErrorCodeRetryLater string = "retry_later" ErrorCodeOperationNotPermitted string = "operation_not_permitteds" ErrorCodeResourceBusy string = "resource_busyr" )
Variables ¶
View Source
var CommonErrorDescriptions = map[string]string{ ErrorCodeUnknown: "Unknown error", ErrorCodeInternalServerError: "Internal server error", ErrorCodeFormat: "Invalid format of request", ErrorCodeFieldValue: "Invalid value of request field", ErrorCodeValidation: "Validation failed", ErrorCodeForbidden: "Access denied", ErrorCodeNotFound: "Resource not found", ErrorCodeExternalServiceUnavailable: "External service is temporarily unavailable", ErrorCodeExternalServiceError: "External service reported error", ErrorCodeUnsupported: "Operation unsupported", ErrorCodeExpired: "Operation expired", ErrorCodeOperationNotPermitted: "Operation not permitted", ErrorCodeRetryLater: "Service is temporarily unavailable, please retry later", ErrorCodeResourceBusy: "Resource is busy, please retry later", }
View Source
var CommonErrorHttpCodes = map[string]int{ ErrorCodeUnknown: http.StatusInternalServerError, ErrorCodeInternalServerError: http.StatusInternalServerError, ErrorCodeForbidden: http.StatusForbidden, ErrorCodeNotFound: http.StatusNotFound, ErrorCodeExternalServiceUnavailable: http.StatusInternalServerError, ErrorCodeExternalServiceError: http.StatusInternalServerError, ErrorCodeRetryLater: http.StatusServiceUnavailable, ErrorCodeOperationNotPermitted: http.StatusForbidden, ErrorCodeResourceBusy: http.StatusServiceUnavailable, }
Functions ¶
func MapErrorData ¶
Types ¶
type Error ¶
type Error interface { error Code() string Message() string Details() string Original() error Data() interface{} SetMessage(msg string) SetDetails(details string) SetOriginal(err error) SetData(data interface{}) }
Generic error that can be forwarded from place of arising to place of user reporting.
type ErrorBase ¶
type ErrorBase struct {
ErrorHolder
}
func NewFromErr ¶
Create new error from code and message taken from other "native error".
func NewFromOriginal ¶
Create new error from code, message and some other "original error" with keeping native error.
type ErrorDefinitions ¶
type ErrorDefinitions interface {
AttachToErrorManager(manager ErrorManager)
}
type ErrorHolder ¶
type ErrorManager ¶
type ErrorManager interface { ErrorDescription(code string, tr ...TranslationHandler) string ErrorProtocolCode(code string) int MakeGenericError(code string, tr ...TranslationHandler) Error AddErrorDescriptions(m map[string]string) AddErrorProtocolCodes(m map[string]int) SetDefaultErrorProtocolCode(code int) DefaultErrorProtocolCode() int }
type ErrorManagerBase ¶
type ErrorManagerBase struct {
// contains filtered or unexported fields
}
func (*ErrorManagerBase) AddErrorDescriptions ¶
func (e *ErrorManagerBase) AddErrorDescriptions(m map[string]string)
func (*ErrorManagerBase) AddErrorProtocolCodes ¶
func (e *ErrorManagerBase) AddErrorProtocolCodes(m map[string]int)
func (*ErrorManagerBase) DefaultErrorProtocolCode ¶
func (e *ErrorManagerBase) DefaultErrorProtocolCode() int
func (*ErrorManagerBase) ErrorDescription ¶
func (e *ErrorManagerBase) ErrorDescription(code string, tr ...TranslationHandler) string
func (*ErrorManagerBase) ErrorProtocolCode ¶
func (e *ErrorManagerBase) ErrorProtocolCode(code string) int
func (*ErrorManagerBase) Init ¶
func (e *ErrorManagerBase) Init(defaultProtocolCode int)
func (*ErrorManagerBase) MakeGenericError ¶
func (e *ErrorManagerBase) MakeGenericError(code string, tr ...TranslationHandler) Error
func (*ErrorManagerBase) SetDefaultErrorProtocolCode ¶
func (e *ErrorManagerBase) SetDefaultErrorProtocolCode(code int)
type ErrorManagerBaseHttp ¶
type ErrorManagerBaseHttp struct {
ErrorManagerBase
}
func (*ErrorManagerBaseHttp) Init ¶
func (e *ErrorManagerBaseHttp) Init()
type ErrorsExtender ¶
type ErrorsExtender interface { ErrorDefinitions AppendErrorExtender(extender ErrorsExtender) Descriptions() map[string]string Codes() map[string]int }
type ErrorsExtenderBase ¶
type ErrorsExtenderBase struct {
// contains filtered or unexported fields
}
func (*ErrorsExtenderBase) AddErrors ¶
func (e *ErrorsExtenderBase) AddErrors(errorDescriptions map[string]string, errorProtocolCodes ...map[string]int)
func (*ErrorsExtenderBase) AppendErrorExtender ¶
func (e *ErrorsExtenderBase) AppendErrorExtender(extender ErrorsExtender)
func (*ErrorsExtenderBase) AttachToErrorManager ¶
func (e *ErrorsExtenderBase) AttachToErrorManager(manager ErrorManager)
func (*ErrorsExtenderBase) Codes ¶
func (e *ErrorsExtenderBase) Codes() map[string]int
func (*ErrorsExtenderBase) Descriptions ¶
func (e *ErrorsExtenderBase) Descriptions() map[string]string
type ErrorsExtenderStub ¶
type ErrorsExtenderStub struct { }
func (*ErrorsExtenderStub) AddErrors ¶
func (e *ErrorsExtenderStub) AddErrors(errorDescriptions map[string]string, errorProtocolCodes ...map[string]int)
func (*ErrorsExtenderStub) AppendErrorExtender ¶
func (e *ErrorsExtenderStub) AppendErrorExtender(extender ErrorsExtender)
func (*ErrorsExtenderStub) AttachToErrorManager ¶
func (e *ErrorsExtenderStub) AttachToErrorManager(manager ErrorManager)
func (*ErrorsExtenderStub) Codes ¶
func (e *ErrorsExtenderStub) Codes() map[string]int
func (*ErrorsExtenderStub) Descriptions ¶
func (e *ErrorsExtenderStub) Descriptions() map[string]string
type TranslationHandler ¶
Click to show internal directories.
Click to hide internal directories.