Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewError ¶
NewError creates an HttpError with a message and optional status code. Defaults to status 500 if none is provided.
func NewFiberErrorHandler ¶
func NewFiberErrorHandler(l logger.Logger, cb ErrorCallback, codes ...int) fiber.ErrorHandler
NewFiberErrorHandler creates a new Fiber error handler with logging and custom error response capabilities. It takes a logger, an optional error callback, and a list of status codes to log. If the error matches one of the provided status codes, it will be logged using the provided logger. If an error callback is provided, it will be used to handle the error response; otherwise, a default plain text response will be sent. For relative file name in log use os.Setenv("APP_ROOT", "your/project/root") to define your project root.
func NewFormError ¶
NewFormError creates an HttpError with a message, request context, and optional status code. Includes request body data if available.
Types ¶
type ErrorCallback ¶
ErrorCallback is a function type that handles custom error responses.
type HttpError ¶
type HttpError struct { Line int // Line number where the error occurred. File string // File name where the error occurred. Body map[string]any // Request body data (if available). Status int // HTTP status code. Message string // Error message. }
HttpError represents an HTTP error with additional context.