Documentation
¶
Index ¶
- type BusinessError
- type DomainError
- func NewAlreadyExistsError(resource string, identifier interface{}) *DomainError
- func NewAuthenticationError(reason string) *DomainError
- func NewAuthorizationError(resource string, action string) *DomainError
- func NewBusinessError(code, message string) *DomainError
- func NewCircuitBreakerOpenError(service string) *DomainError
- func NewConfigurationError(setting string, reason string) *DomainError
- func NewDatabaseError(operation string, cause error) *DomainError
- func NewDomainError(code, message string, category ErrorCategory, severity ErrorSeverity) *DomainError
- func NewExpiredTokenError(tokenType string) *DomainError
- func NewExternalServiceError(service string, cause error) *DomainError
- func NewInsufficientPermissionsError(action string, resource string) *DomainError
- func NewInternalError(message string, cause error) *DomainError
- func NewInvalidFormatError(field string, value interface{}, expectedFormat string) *DomainError
- func NewInvalidTokenError(tokenType string) *DomainError
- func NewInvalidValueError(field string, value interface{}, validValues []interface{}) *DomainError
- func NewNotFoundError(resource string, identifier interface{}) *DomainError
- func NewRateLimitExceededError(limit int, windowSeconds int) *DomainError
- func NewRequiredFieldError(field string) *DomainError
- func NewServiceUnavailableError(service string) *DomainError
- func NewTimeoutError(operation string, timeoutSeconds int) *DomainError
- func NewValidationError(message string, field string, value interface{}) *DomainError
- func (e *DomainError) Error() string
- func (e *DomainError) GenerateFingerprint() string
- func (e *DomainError) Is(target error) bool
- func (e *DomainError) IsRetryable() bool
- func (e *DomainError) IsTransient() bool
- func (e *DomainError) ToHTTPResponse() HTTPErrorResponse
- func (e *DomainError) ToJSON() ([]byte, error)
- func (e *DomainError) Unwrap() error
- func (e *DomainError) WithCause(cause error) *DomainError
- func (e *DomainError) WithContext(ctx *ErrorContext) *DomainError
- func (e *DomainError) WithMetadata(key string, value interface{}) *DomainError
- func (e *DomainError) WithStackTrace(skip int) *DomainError
- func (e *DomainError) WithTags(tags ...string) *DomainError
- type ErrorCategory
- type ErrorContext
- type ErrorSeverity
- type HTTPError
- type HTTPErrorResponse
- type IntegrationError
- type SecurityError
- type StackFrame
- type StackTrace
- type ValidationError
- type ValidationErrorResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BusinessError ¶
type BusinessError struct { Rule string `json:"rule"` Description string `json:"description"` Context map[string]interface{} `json:"context,omitempty"` }
BusinessError representa un error de lógica de negocio
type DomainError ¶
type DomainError struct { // Información básica del error ID string `json:"id"` Code string `json:"code"` Message string `json:"message"` Category ErrorCategory `json:"category"` Severity ErrorSeverity `json:"severity"` // Información de contexto Context *ErrorContext `json:"context"` // Stack trace y debugging StackTrace *StackTrace `json:"stack_trace,omitempty"` Cause error `json:"-"` // Error original (no serializable) CauseMsg string `json:"cause,omitempty"` // Información HTTP StatusCode int `json:"-"` // Información adicional Details map[string]interface{} `json:"details,omitempty"` Timestamp time.Time `json:"timestamp"` Retryable bool `json:"retryable"` Transient bool `json:"transient"` // Información de debugging Fingerprint string `json:"fingerprint,omitempty"` // Para agrupar errores similares Tags []string `json:"tags,omitempty"` }
DomainError representa un error de dominio con información rica para debugging
func NewAlreadyExistsError ¶
func NewAlreadyExistsError(resource string, identifier interface{}) *DomainError
NewAlreadyExistsError crea un error de recurso ya existente
func NewAuthenticationError ¶
func NewAuthenticationError(reason string) *DomainError
NewAuthenticationError crea un error de autenticación
func NewAuthorizationError ¶
func NewAuthorizationError(resource string, action string) *DomainError
NewAuthorizationError crea un error de autorización
func NewBusinessError ¶
func NewBusinessError(code, message string) *DomainError
NewBusinessError crea un error de lógica de negocio
func NewCircuitBreakerOpenError ¶
func NewCircuitBreakerOpenError(service string) *DomainError
NewCircuitBreakerOpenError crea un error de circuit breaker abierto
func NewConfigurationError ¶
func NewConfigurationError(setting string, reason string) *DomainError
NewConfigurationError crea un error de configuración
func NewDatabaseError ¶
func NewDatabaseError(operation string, cause error) *DomainError
NewDatabaseError crea un error de base de datos
func NewDomainError ¶
func NewDomainError(code, message string, category ErrorCategory, severity ErrorSeverity) *DomainError
NewDomainError crea un nuevo error de dominio
func NewExpiredTokenError ¶
func NewExpiredTokenError(tokenType string) *DomainError
NewExpiredTokenError crea un error de token expirado
func NewExternalServiceError ¶
func NewExternalServiceError(service string, cause error) *DomainError
NewExternalServiceError crea un error de servicio externo
func NewInsufficientPermissionsError ¶
func NewInsufficientPermissionsError(action string, resource string) *DomainError
NewInsufficientPermissionsError crea un error de permisos insuficientes
func NewInternalError ¶
func NewInternalError(message string, cause error) *DomainError
NewInternalError crea un error interno del servidor
func NewInvalidFormatError ¶
func NewInvalidFormatError(field string, value interface{}, expectedFormat string) *DomainError
NewInvalidFormatError crea un error de formato inválido
func NewInvalidTokenError ¶
func NewInvalidTokenError(tokenType string) *DomainError
NewInvalidTokenError crea un error de token inválido
func NewInvalidValueError ¶
func NewInvalidValueError(field string, value interface{}, validValues []interface{}) *DomainError
NewInvalidValueError crea un error de valor inválido
func NewNotFoundError ¶
func NewNotFoundError(resource string, identifier interface{}) *DomainError
NewNotFoundError crea un error de recurso no encontrado
func NewRateLimitExceededError ¶
func NewRateLimitExceededError(limit int, windowSeconds int) *DomainError
NewRateLimitExceededError crea un error de rate limit excedido
func NewRequiredFieldError ¶
func NewRequiredFieldError(field string) *DomainError
NewRequiredFieldError crea un error de campo requerido
func NewServiceUnavailableError ¶
func NewServiceUnavailableError(service string) *DomainError
NewServiceUnavailableError crea un error de servicio no disponible
func NewTimeoutError ¶
func NewTimeoutError(operation string, timeoutSeconds int) *DomainError
NewTimeoutError crea un error de timeout
func NewValidationError ¶
func NewValidationError(message string, field string, value interface{}) *DomainError
NewValidationError crea un error de validación
func (*DomainError) GenerateFingerprint ¶
func (e *DomainError) GenerateFingerprint() string
GenerateFingerprint genera un fingerprint único para agrupar errores similares
func (*DomainError) Is ¶
func (e *DomainError) Is(target error) bool
Is permite comparación de errores
func (*DomainError) IsRetryable ¶
func (e *DomainError) IsRetryable() bool
IsRetryable indica si el error puede ser reintentado
func (*DomainError) IsTransient ¶
func (e *DomainError) IsTransient() bool
IsTransient indica si el error es transitorio
func (*DomainError) ToHTTPResponse ¶
func (e *DomainError) ToHTTPResponse() HTTPErrorResponse
ToHTTPResponse convierte el error a respuesta HTTP
func (*DomainError) ToJSON ¶
func (e *DomainError) ToJSON() ([]byte, error)
ToJSON serializa el error a JSON
func (*DomainError) Unwrap ¶
func (e *DomainError) Unwrap() error
Unwrap permite unwrapping del error original
func (*DomainError) WithCause ¶
func (e *DomainError) WithCause(cause error) *DomainError
WithCause añade la causa del error
func (*DomainError) WithContext ¶
func (e *DomainError) WithContext(ctx *ErrorContext) *DomainError
WithContext añade contexto al error
func (*DomainError) WithMetadata ¶
func (e *DomainError) WithMetadata(key string, value interface{}) *DomainError
WithMetadata añade metadata al error
func (*DomainError) WithStackTrace ¶
func (e *DomainError) WithStackTrace(skip int) *DomainError
WithStackTrace añade stack trace al error
func (*DomainError) WithTags ¶
func (e *DomainError) WithTags(tags ...string) *DomainError
WithTags añade tags para clasificación
type ErrorCategory ¶
type ErrorCategory string
ErrorCategory define la categoría del error
const ( CategoryValidation ErrorCategory = "validation" CategoryBusiness ErrorCategory = "business" CategoryTechnical ErrorCategory = "technical" CategorySecurity ErrorCategory = "security" CategoryIntegration ErrorCategory = "integration" CategoryPerformance ErrorCategory = "performance" CategoryInfrastructure ErrorCategory = "infrastructure" )
type ErrorContext ¶
type ErrorContext struct { Service string `json:"service"` Version string `json:"version"` RequestID string `json:"request_id"` CorrelationID string `json:"correlation_id"` UserID string `json:"user_id,omitempty"` TenantID string `json:"tenant_id,omitempty"` SessionID string `json:"session_id,omitempty"` Timestamp time.Time `json:"timestamp"` Environment string `json:"environment"` Metadata map[string]interface{} `json:"metadata,omitempty"` TraceID string `json:"trace_id,omitempty"` SpanID string `json:"span_id,omitempty"` }
ErrorContext proporciona contexto rico para errores
type ErrorSeverity ¶
type ErrorSeverity string
ErrorSeverity define la severidad del error
const ( SeverityLow ErrorSeverity = "low" SeverityMedium ErrorSeverity = "medium" SeverityHigh ErrorSeverity = "high" SeverityCritical ErrorSeverity = "critical" )
type HTTPError ¶
type HTTPError struct { Code string `json:"code"` Message string `json:"message"` Category string `json:"category"` Severity string `json:"severity"` Details map[string]interface{} `json:"details,omitempty"` Field string `json:"field,omitempty"` Value interface{} `json:"value,omitempty"` RequestID string `json:"request_id,omitempty"` CorrelationID string `json:"correlation_id,omitempty"` TraceID string `json:"trace_id,omitempty"` Timestamp time.Time `json:"timestamp"` Retryable bool `json:"retryable"` Transient bool `json:"transient"` HelpURL string `json:"help_url,omitempty"` }
HTTPError representa un error HTTP para respuestas API
type HTTPErrorResponse ¶
HTTPErrorResponse representa la respuesta de error completa
type IntegrationError ¶
type IntegrationError struct { Service string `json:"service"` Endpoint string `json:"endpoint,omitempty"` Method string `json:"method,omitempty"` StatusCode int `json:"status_code,omitempty"` Response string `json:"response,omitempty"` Timeout bool `json:"timeout"` NetworkError bool `json:"network_error"` Metadata map[string]interface{} `json:"metadata,omitempty"` }
IntegrationError representa un error de integración con servicios externos
type SecurityError ¶
type SecurityError struct { Threat string `json:"threat"` Action string `json:"action"` Severity string `json:"severity"` RemoteIP string `json:"remote_ip,omitempty"` UserAgent string `json:"user_agent,omitempty"` BlockedTime *time.Time `json:"blocked_until,omitempty"` }
SecurityError representa un error de seguridad
type StackFrame ¶
type StackFrame struct { Function string `json:"function"` File string `json:"file"` Line int `json:"line"` Package string `json:"package"` }
StackFrame representa un frame en el stack trace
type StackTrace ¶
type StackTrace struct { Frames []StackFrame `json:"frames"` Raw string `json:"raw"` }
StackTrace representa un stack trace completo
type ValidationError ¶
type ValidationError struct { Field string `json:"field"` Value interface{} `json:"value"` Tag string `json:"tag"` Message string `json:"message"` }
ValidationError representa un error de validación específico
type ValidationErrorResponse ¶
type ValidationErrorResponse struct { Error HTTPError `json:"error"` Errors []ValidationError `json:"validation_errors"` }
ValidationErrorResponse representa una respuesta con múltiples errores de validación