Documentation ¶
Index ¶
- Variables
- func BasicAuthValidator(basicAuthUser string, basicAuthPassword string) middleware.BasicAuthValidator
- func CustomErrorHandler[E ApiError](errorHandler ErrorHandler[E]) func(error, echo.Context)
- func LogHttpError(logger *logrus.Entry, path string, code int, err error)
- type ApiError
- type Error
- type ErrorHandler
- type ErrorResponse
- type SiteId
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSiteMissing = Error{ErrorCode: "SITE_MISSING", ErrorDescription: "missing site", HttpStatusCode: http.StatusBadRequest} ErrUnknown = Error{ErrorCode: "UNKNOWN_ERROR", ErrorDescription: "error is unknown", HttpStatusCode: http.StatusInternalServerError} ErrTimeout = Error{ErrorCode: "TIMEOUT", ErrorDescription: "request timeout", HttpStatusCode: 499} ErrInternalServerError = Error{ErrorCode: "INTERNAL_SERVER_ERROR", ErrorDescription: "internal server error", HttpStatusCode: http.StatusInternalServerError} )
Functions ¶
func BasicAuthValidator ¶ added in v2.3.39
func BasicAuthValidator(basicAuthUser string, basicAuthPassword string) middleware.BasicAuthValidator
func CustomErrorHandler ¶ added in v2.3.22
func CustomErrorHandler[E ApiError](errorHandler ErrorHandler[E]) func(error, echo.Context)
Types ¶
type ApiError ¶ added in v2.3.37
type ApiError interface { error ToErrorResponse() ErrorResponse }
type Error ¶
type Error struct { ErrorCode string `json:"errorCode"` ErrorDescription string `json:"errorDescription"` Field *string `json:"field,omitempty"` Info *map[string]interface{} `json:"info,omitempty"` HttpStatusCode int `json:"-"` BaseError error `json:"-"` }
func (Error) ToErrorResponse ¶
func (e Error) ToErrorResponse() ErrorResponse
func (Error) WithBaseError ¶ added in v2.3.58
type ErrorHandler ¶ added in v2.3.18
type ErrorHandler[E ApiError] struct { UnknownError func(msg string) error TimeoutError func(msg string) ApiError HttpStatusFrom func(ctx context.Context, err error) int ToApiError func(err error) E }
func (*ErrorHandler[E]) HandleError ¶ added in v2.3.18
func (eh *ErrorHandler[E]) HandleError(ctx context.Context, c echo.Context, err error)
type ErrorResponse ¶
type ErrorResponse struct { MainError Error `json:"mainError"` AllErrors []Error `json:"allErrors"` }
func NewErrorResponse ¶
func NewErrorResponse(errorCode string, errorDescription string, field string, info map[string]interface{}) ErrorResponse
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
Click to show internal directories.
Click to hide internal directories.