Documentation
¶
Overview ¶
Package response provides HTTP response handling utilities including error handling, response building, and standardized response formats.
Package response provides HTTP response handling utilities including error handling, response building, and standardized response formats.
Index ¶
- func ErrorResponse(c echo.Context, statusCode int, message string) error
- func Success(c echo.Context, data any) error
- type APIResponse
- type ErrorHandler
- func (h *ErrorHandler) HandleAuthError(err error, c echo.Context) error
- func (h *ErrorHandler) HandleDomainError(err *domainerrors.DomainError, c echo.Context) error
- func (h *ErrorHandler) HandleError(_ error, c echo.Context, message string) error
- func (h *ErrorHandler) HandleNotFoundError(resource string, c echo.Context) error
- type ErrorHandlerInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorResponse ¶ added in v0.1.5
ErrorResponse sends an error response with a custom status code
Types ¶
type APIResponse ¶ added in v0.1.5
type APIResponse struct {
Success bool `json:"success"`
Message string `json:"message,omitempty"`
Data any `json:"data,omitempty"`
}
APIResponse represents a standardized API response structure
type ErrorHandler ¶ added in v0.1.5
type ErrorHandler struct {
// contains filtered or unexported fields
}
ErrorHandler provides unified error handling across the application
func NewErrorHandler ¶ added in v0.1.5
func NewErrorHandler(logger logging.Logger, sanitizer sanitization.ServiceInterface) *ErrorHandler
NewErrorHandler creates a new error handler instance
func (*ErrorHandler) HandleAuthError ¶ added in v0.1.5
func (h *ErrorHandler) HandleAuthError(err error, c echo.Context) error
HandleAuthError handles authentication errors
func (*ErrorHandler) HandleDomainError ¶ added in v0.1.5
func (h *ErrorHandler) HandleDomainError(err *domainerrors.DomainError, c echo.Context) error
HandleDomainError handles domain-specific errors
func (*ErrorHandler) HandleError ¶ added in v0.1.5
HandleError handles generic errors
func (*ErrorHandler) HandleNotFoundError ¶ added in v0.1.5
func (h *ErrorHandler) HandleNotFoundError(resource string, c echo.Context) error
HandleNotFoundError handles not found errors
type ErrorHandlerInterface ¶ added in v0.1.5
type ErrorHandlerInterface interface {
HandleError(err error, c echo.Context, message string) error
HandleDomainError(err *domainerrors.DomainError, c echo.Context) error
HandleAuthError(err error, c echo.Context) error
HandleNotFoundError(resource string, c echo.Context) error
}
ErrorHandlerInterface defines the interface for error handling