Documentation
¶
Index ¶
- Constants
- func Middleware() fiber.ErrorHandler
- type Error
- func CSRFInvalid() *Error
- func Forbidden(resource, action string) *Error
- func InternalServerError() *Error
- func InvalidRequestBody() *Error
- func New(httpStatus int, code, message string) *Error
- func NotImplemented() *Error
- func RateLimited() *Error
- func Unauthorized() *Error
- func UserPrincipalRequired() *Error
- func ValidationFailed(message string) *Error
- type ErrorResponse
- type ValidationError
Constants ¶
View Source
const ( // Authentication & Authorization CodeAuthForbidden = "AUTH_FORBIDDEN" CodeAuthUserPrincipalRequired = "AUTH_USER_PRINCIPAL_REQUIRED" CodeCSRFInvalid = "CSRF_INVALID" CodeRateLimited = "RATE_LIMITED" // Validation CodeValidationFailed = "VALIDATION_FAILED" CodeValidationRequiredField = "VALIDATION_REQUIRED_FIELD" CodeValidationInvalidFormat = "VALIDATION_INVALID_FORMAT" // Validation - Specific field types CodeEmailInvalid = "EMAIL_INVALID" CodeValueTooShort = "VALUE_TOO_SHORT" CodeValueTooLong = "VALUE_TOO_LONG" CodeValueInvalidLength = "VALUE_INVALID_LENGTH" CodeValueNotInList = "VALUE_NOT_IN_LIST" CodeUUIDInvalid = "UUID_INVALID" CodeURLInvalid = "URL_INVALID" CodeDatetimeInvalid = "DATETIME_INVALID" // System CodeInternalServerError = "INTERNAL_SERVER_ERROR" CodeNotImplemented = "NOT_IMPLEMENTED" CodeMethodNotAllowed = "METHOD_NOT_ALLOWED" )
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware() fiber.ErrorHandler
Middleware is a Fiber middleware that converts errors to structured API responses
Types ¶
type Error ¶
type Error struct {
Code string `json:"code"`
Message string `json:"message"`
DetailedError string `json:"detailed_error,omitempty"`
ValidationErrors []ValidationError `json:"validation_errors,omitempty"`
RequestID string `json:"request_id,omitempty"`
// Internal fields (not serialized)
HTTPStatus int `json:"-"`
}
Error represents a structured API error
func CSRFInvalid ¶
func CSRFInvalid() *Error
func InternalServerError ¶
func InternalServerError() *Error
func InvalidRequestBody ¶
func InvalidRequestBody() *Error
func NotImplemented ¶
func NotImplemented() *Error
func RateLimited ¶
func RateLimited() *Error
func Unauthorized ¶
func Unauthorized() *Error
func UserPrincipalRequired ¶
func UserPrincipalRequired() *Error
func ValidationFailed ¶
func (*Error) WithDetailedError ¶
WithDetailedError adds backend diagnostic details for disclosure UIs.
type ErrorResponse ¶
type ErrorResponse struct {
Error *Error `json:"error"`
}
ErrorResponse wraps the error for API responses
func OapiValidationFailed ¶
func OapiValidationFailed(message, requestID string, statusCode int) ErrorResponse
type ValidationError ¶
type ValidationError struct {
Field string `json:"field"`
Code string `json:"code"`
Message string `json:"message"`
}
ValidationError represents a field-level validation error
Click to show internal directories.
Click to hide internal directories.