Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewError ¶
NewError creates a new HttpError with the provided error message and optional status code. If no status code is provided, it defaults to 500. It also captures the file and line number where the error occurred.
func NewFiberErrorHandler ¶
func NewFiberErrorHandler(l gologger.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 a new HttpError with the provided error message, request context, and optional status code. It captures the file and line number where the error occurred and 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.
Status int // HTTP status code.
Message string // Error message.
}
HttpError represents an HTTP error with additional context information.