Versions in this module Expand all Collapse all v1 v1.0.0 May 19, 2026 Changes in this version + func Is(err error, code ErrorCode) bool + type Error struct + Cause error + Code ErrorCode + Details map[string]interface{} + Message string + RequestID string + Severity ErrorSeverity + StackTrace []string + TenantID string + Timestamp time.Time + UserID string + func BadRequest(message string) *Error + func Forbidden(message string) *Error + func Internal(message string) *Error + func Internalf(format string, args ...interface{}) *Error + func New(code ErrorCode, message string) *Error + func Newf(code ErrorCode, format string, args ...interface{}) *Error + func NotFound(message string) *Error + func Unauthorized(message string) *Error + func Validation(message string) *Error + func Wrap(err error, code ErrorCode, message string) *Error + func Wrapf(err error, code ErrorCode, format string, args ...interface{}) *Error + func (e *Error) Error() string + func (e *Error) HTTPStatus() int + func (e *Error) Unwrap() error + func (e *Error) WithCause(cause error) *Error + func (e *Error) WithDetail(key string, value interface{}) *Error + func (e *Error) WithRequestID(requestID string) *Error + func (e *Error) WithStackTrace() *Error + func (e *Error) WithTenantID(tenantID string) *Error + func (e *Error) WithUserID(userID string) *Error + type ErrorCode string + const ErrCodeAccountDisabled + const ErrCodeAccountLocked + const ErrCodeBadRequest + const ErrCodeConflict + const ErrCodeDatabaseConnection + const ErrCodeDatabaseConstraint + const ErrCodeDatabaseMigration + const ErrCodeDatabaseTimeout + const ErrCodeExternalService + const ErrCodeFileNotFound + const ErrCodeFileTooLarge + const ErrCodeFileTypeInvalid + const ErrCodeForbidden + const ErrCodeInsufficientPermissions + const ErrCodeInternal + const ErrCodeInvalidCredentials + const ErrCodeInvalidEmail + const ErrCodeInvalidFormat + const ErrCodeInvalidLength + const ErrCodeInvalidRange + const ErrCodeInvalidURL + const ErrCodeLimitExceeded + const ErrCodeNotFound + const ErrCodePaymentRequired + const ErrCodeQuotaExceeded + const ErrCodeRateLimit + const ErrCodeRequiredField + const ErrCodeResourceExists + const ErrCodeResourceNotFound + const ErrCodeRoleRequired + const ErrCodeScopeRequired + const ErrCodeStorageQuota + const ErrCodeSubscriptionExpired + const ErrCodeTenantExists + const ErrCodeTenantNotFound + const ErrCodeTimeout + const ErrCodeTokenExpired + const ErrCodeTokenInvalid + const ErrCodeUnauthorized + const ErrCodeUnavailable + const ErrCodeUploadFailed + const ErrCodeUserExists + const ErrCodeUserNotFound + const ErrCodeValidation + func GetCode(err error) ErrorCode + type ErrorHandler struct + func NewErrorHandler(logger Logger, config HandlerConfig) *ErrorHandler + func (eh *ErrorHandler) Handle(err error, requestID, userID, tenantID string) *ErrorResponse + type ErrorInfo struct + Code string + Details map[string]interface{} + Message string + StackTrace []string + Timestamp time.Time + type ErrorResponse struct + Error ErrorInfo + RequestID string + Status int + func (er *ErrorResponse) JSON() ([]byte, error) + type ErrorSeverity string + const SeverityCritical + const SeverityHigh + const SeverityLow + const SeverityMedium + func GetSeverity(err error) ErrorSeverity + type HandlerConfig struct + IncludeDetails bool + IncludeStackTrace bool + LogLevel ErrorSeverity + type Logger interface + Debug func(msg string, fields ...interface{}) + Error func(msg string, fields ...interface{}) + Info func(msg string, fields ...interface{}) + Warn func(msg string, fields ...interface{}) + type RecoveryMiddleware struct + func NewRecoveryMiddleware(errorHandler *ErrorHandler, logger Logger) *RecoveryMiddleware + func (rm *RecoveryMiddleware) Recover(requestID, userID, tenantID string) error + type ValidationError struct + Errors map[string]string + func NewValidationError(errors map[string]string) *ValidationError + func (ve *ValidationError) Add(field, message string) + func (ve *ValidationError) Error() string + func (ve *ValidationError) Has() bool + func (ve *ValidationError) ToAstraError() *Error