Documentation ¶
Index ¶
- Variables
- func CreateErrorParseRequestBody(err error) error
- func RestErrorHandler(response *resty.Response, err error) error
- type ApiErrors
- type Caller
- type ClassError
- type TypedError
- func ExceptionClientError(msg string, Status int) TypedError
- func ExceptionEntityNotFound(msg string) TypedError
- func ExceptionFormatError(msg string) TypedError
- func ExceptionFraudDetect(msg string) TypedError
- func ExceptionIllegalArgument(arg, msg string) TypedError
- func ExceptionIllegalState(msg string) TypedError
- func ExceptionInternalError(msg string) TypedError
- func ExceptionInternalErrorE(err error) TypedError
- func ExceptionInvalidValue(msg string) TypedError
- func ExceptionUnauthorized(msg string) TypedError
- func IntegrationExceptionServerErrorR(msg string, response *resty.Response) TypedError
- func IntegratrionExceptionClientErrorR(response *resty.Response) TypedError
- func NewPersisnteceError(err error) TypedError
- func NewPersisnteceErrorM(message string, err error) TypedError
- func NewValidatorError(message string) TypedError
- type TypedErrorStr
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorPrefix = map[ClassError]string{ EXCEPTION_UNAUTHORIZED: "Unauthorized: ", ERROR_PARSE_REQUEST_BODY: "Error parse request body: ", INTEGRATION_EXCEPTION_SERVER_ERROR: "Integration Server Error: ", INTEGRATION_EXCEPTION_CLIENT_ERROR: "Integration Client Error: ", EXCEPTION_ILLEGAL_ARGUMENT: "Illegal argument: ", EXCEPTION_ILLEGAL_STATE: "Illegal state: ", EXCEPTION_INTERNAL_ERROR: "Internal Error: ", EXCEPTION_ENTITY_NOT_FOUND: "Entity Not Found: ", PERSISTENCE_ERROR: "Persistence error: ", }
Functions ¶
func RestErrorHandler ¶
Types ¶
type ApiErrors ¶
type ApiErrors struct {
Errors []*TypedErrorStr `json_off:"errors"`
}
type ClassError ¶
type ClassError string
const ( EXCEPTION_UNAUTHORIZED ClassError = "EXCEPTION_UNAUTHORIZED" ERROR_PARSE_REQUEST_BODY ClassError = "ERROR_PARSE_REQUEST_BODY" INTEGRATION_EXCEPTION_SERVER_ERROR ClassError = "INTEGRATION_EXCEPTION_SERVER_ERROR" INTEGRATION_EXCEPTION_CLIENT_ERROR ClassError = "INTEGRATION_EXCEPTION_CLIENT_ERROR" EXCEPTION_ILLEGAL_ARGUMENT ClassError = "EXCEPTION_ILLEGAL_ARGUMENT" EXCEPTION_ILLEGAL_STATE ClassError = "EXCEPTION_ILLEGAL_STATE" EXCEPTION_INVALID_VALUE ClassError = "EXCEPTION_INVALID_VALUE" EXCEPTION_FRAUD_DETECT ClassError = "EXCEPTION_FRAUD_DETECT" EXCEPTION_INTERNAL_ERROR ClassError = "EXCEPTION_INTERNAL_ERROR" EXCEPTION_FORMAT_ERROR ClassError = "EXCEPTION_FORMAT_ERROR" EXCEPTION_ENTITY_NOT_FOUND ClassError = "EXCEPTION_ENTITY_NOT_FOUND" PERSISTENCE_ERROR ClassError = "PERSISTENCE_ERROR" )
type TypedError ¶
type TypedError interface { Error() string Type() ClassError Message() string }
func ExceptionClientError ¶
func ExceptionClientError(msg string, Status int) TypedError
func ExceptionEntityNotFound ¶
func ExceptionEntityNotFound(msg string) TypedError
func ExceptionFormatError ¶
func ExceptionFormatError(msg string) TypedError
func ExceptionFraudDetect ¶
func ExceptionFraudDetect(msg string) TypedError
func ExceptionIllegalArgument ¶
func ExceptionIllegalArgument(arg, msg string) TypedError
func ExceptionIllegalState ¶
func ExceptionIllegalState(msg string) TypedError
func ExceptionInternalError ¶
func ExceptionInternalError(msg string) TypedError
func ExceptionInternalErrorE ¶
func ExceptionInternalErrorE(err error) TypedError
func ExceptionInvalidValue ¶
func ExceptionInvalidValue(msg string) TypedError
func ExceptionUnauthorized ¶
func ExceptionUnauthorized(msg string) TypedError
func IntegrationExceptionServerErrorR ¶
func IntegrationExceptionServerErrorR(msg string, response *resty.Response) TypedError
func IntegratrionExceptionClientErrorR ¶
func IntegratrionExceptionClientErrorR(response *resty.Response) TypedError
func NewPersisnteceError ¶
func NewPersisnteceError(err error) TypedError
todo wrap all Err in all repositories
func NewPersisnteceErrorM ¶
func NewPersisnteceErrorM(message string, err error) TypedError
func NewValidatorError ¶
func NewValidatorError(message string) TypedError
To handle the error returned by c.Bind in gin framework https://github.com/go-playground/validator/blob/v9/_examples/translations/main.go
type TypedErrorStr ¶
type TypedErrorStr struct { Class ClassError `json:"Class,omitempty"` //TraceId string Msg string `json:"Message,omitempty" example:"status bad request" || "Not found"` // the HTTP status code applicable to this problem, expressed as a string value. Status int `json:"State,omitempty" example:"5xx" or "4xxx"` // an application-specific error code, expressed as a string value //Code string `json:"Code" example:"database_error" or "invalid_group"` Err error `json:"-"` // a short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence of the problem, except for purposes of localization. Title string `json:"Title,omitempty"` // a human-readable explanation specific to this occurrence of the problem. Like title, this field’s value can be localized. Details interface{} `json:"Details,omitempty"` Caller Caller `json:"-"` }
func (TypedErrorStr) Error ¶
func (this TypedErrorStr) Error() string
func (TypedErrorStr) Message ¶
func (this TypedErrorStr) Message() string
func (TypedErrorStr) Type ¶
func (this TypedErrorStr) Type() ClassError
Click to show internal directories.
Click to hide internal directories.