apperr

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InternalErrorType type of common errors
	InternalErrorType = "INTERNAL"
	// GenericErrorType type of common errors
	GenericErrorType = "GENERIC"
	// ValidationErrorType type of common errors
	ValidationErrorType = "VALIDATION"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorHandler

type ErrorHandler struct {
	// contains filtered or unexported fields
}

ErrorHandler represents the custom http error handler

func NewErrorHandler

func NewErrorHandler(e *echo.Echo) *ErrorHandler

NewErrorHandler returns the ErrorHandler instance

func (*ErrorHandler) Handle

func (ce *ErrorHandler) Handle(err error, c echo.Context)

Handle is a centralized HTTP error handler.

type ErrorResponse

type ErrorResponse struct {
	Error *HTTPError `json:"error"`

} //	@name	ErrorResponse

ErrorResponse represents the error response

type HTTPError

type HTTPError struct {
	Code     int    `json:"code"`
	Type     string `json:"type"`
	Message  string `json:"message"`
	Internal error  `json:"-"`

} //	@name	ErrorResponse

HTTPError represents an error that occurred while handling a request

func NewHTTPError

func NewHTTPError(code int, etype string, message ...string) *HTTPError

NewHTTPError creates a new HTTPError instance

func NewHTTPGenericError

func NewHTTPGenericError(message string) *HTTPError

NewHTTPGenericError creates a new HTTPError instance for generic error

func NewHTTPInternalError

func NewHTTPInternalError(message string) *HTTPError

NewHTTPInternalError creates a new HTTPError instance for internal error

func NewHTTPValidationError

func NewHTTPValidationError(message string) *HTTPError

NewHTTPValidationError creates a new HTTPError instance for validation error

func (*HTTPError) Error

func (he *HTTPError) Error() string

Error makes it compatible with `error` interface

func (*HTTPError) SetInternal

func (he *HTTPError) SetInternal(err error) *HTTPError

SetInternal sets actual internal error for more details

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL