{"modulePath":"github.com/lukcba-developers/gopherkit","version":"v1.0.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errors\n\n## Types\n\n```go\ntype BusinessError struct {\n\tRule        string                 `json:\"rule\"`\n\tDescription string                 `json:\"description\"`\n\tContext     map[string]interface{} `json:\"context,omitempty\"`\n}\n```\nBusinessError representa un error de lógica de negocio\n\n```go\ntype DomainError struct {\n\t// Información básica del error\n\tID       string        `json:\"id\"`\n\tCode     string        `json:\"code\"`\n\tMessage  string        `json:\"message\"`\n\tCategory ErrorCategory `json:\"category\"`\n\tSeverity ErrorSeverity `json:\"severity\"`\n\n\t// Información de contexto\n\tContext *ErrorContext `json:\"context\"`\n\n\t// Stack trace y debugging\n\tStackTrace *StackTrace `json:\"stack_trace,omitempty\"`\n\tCause      error       `json:\"-\"` // Error original (no serializable)\n\tCauseMsg   string      `json:\"cause,omitempty\"`\n\n\t// Información HTTP\n\tStatusCode int `json:\"-\"`\n\n\t// Información adicional\n\tDetails   map[string]interface{} `json:\"details,omitempty\"`\n\tTimestamp time.Time              `json:\"timestamp\"`\n\tRetryable bool                   `json:\"retryable\"`\n\tTransient bool                   `json:\"transient\"`\n\n\t// Información de debugging\n\tFingerprint string   `json:\"fingerprint,omitempty\"` // Para agrupar errores similares\n\tTags        []string `json:\"tags,omitempty\"`\n}\n```\nDomainError representa un error de dominio con información rica para debugging\n\n```go\nfunc NewAlreadyExistsError(resource string, identifier interface{}) *DomainError\n```\nNewAlreadyExistsError crea un error de recurso ya existente\n\n```go\nfunc NewAuthenticationError(reason string) *DomainError\n```\nNewAuthenticationError crea un error de autenticación\n\n```go\nfunc NewAuthorizationError(resource string, action string) *DomainError\n```\nNewAuthorizationError crea un error de autorización\n\n```go\nfunc NewBusinessError(code, message string) *DomainError\n```\nNewBusinessError crea un error de lógica de negocio\n\n```go\nfunc NewCircuitBreakerOpenError(service string) *DomainError\n```\nNewCircuitBreakerOpenError crea un error de circuit breaker abierto\n\n```go\nfunc NewConfigurationError(setting string, reason string) *DomainError\n```\nNewConfigurationError crea un error de configuración\n\n```go\nfunc NewDatabaseError(operation string, cause error) *DomainError\n```\nNewDatabaseError crea un error de base de datos\n\n```go\nfunc NewDomainError(code, message string, category ErrorCategory, severity ErrorSeverity) *DomainError\n```\nNewDomainError crea un nuevo error de dominio\n\n```go\nfunc NewExpiredTokenError(tokenType string) *DomainError\n```\nNewExpiredTokenError crea un error de token expirado\n\n```go\nfunc NewExternalServiceError(service string, cause error) *DomainError\n```\nNewExternalServiceError crea un error de servicio externo\n\n```go\nfunc NewInsufficientPermissionsError(action string, resource string) *DomainError\n```\nNewInsufficientPermissionsError crea un error de permisos insuficientes\n\n```go\nfunc NewInternalError(message string, cause error) *DomainError\n```\nNewInternalError crea un error interno del servidor\n\n```go\nfunc NewInvalidFormatError(field string, value interface{}, expectedFormat string) *DomainError\n```\nNewInvalidFormatError crea un error de formato inválido\n\n```go\nfunc NewInvalidTokenError(tokenType string) *DomainError\n```\nNewInvalidTokenError crea un error de token inválido\n\n```go\nfunc NewInvalidValueError(field string, value interface{}, validValues []interface{}) *DomainError\n```\nNewInvalidValueError crea un error de valor inválido\n\n```go\nfunc NewNotFoundError(resource string, identifier interface{}) *DomainError\n```\nNewNotFoundError crea un error de recurso no encontrado\n\n```go\nfunc NewRateLimitExceededError(limit int, windowSeconds int) *DomainError\n```\nNewRateLimitExceededError crea un error de rate limit excedido\n\n```go\nfunc NewRequiredFieldError(field string) *DomainError\n```\nNewRequiredFieldError crea un error de campo requerido\n\n```go\nfunc NewServiceUnavailableError(service string) *DomainError\n```\nNewServiceUnavailableError crea un error de servicio no disponible\n\n```go\nfunc NewTimeoutError(operation string, timeoutSeconds int) *DomainError\n```\nNewTimeoutError crea un error de timeout\n\n```go\nfunc NewValidationError(message string, field string, value interface{}) *DomainError\n```\nNewValidationError crea un error de validación\n\n```go\nfunc (e *DomainError) Error() string\n```\nError implementa la interfaz error\n\n```go\nfunc (e *DomainError) GenerateFingerprint() string\n```\nGenerateFingerprint genera un fingerprint único para agrupar errores similares\n\n```go\nfunc (e *DomainError) Is(target error) bool\n```\nIs permite comparación de errores\n\n```go\nfunc (e *DomainError) IsRetryable() bool\n```\nIsRetryable indica si el error puede ser reintentado\n\n```go\nfunc (e *DomainError) IsTransient() bool\n```\nIsTransient indica si el error es transitorio\n\n```go\nfunc (e *DomainError) ToHTTPResponse() HTTPErrorResponse\n```\nToHTTPResponse convierte el error a respuesta HTTP\n\n```go\nfunc (e *DomainError) ToJSON() ([]byte, error)\n```\nToJSON serializa el error a JSON\n\n```go\nfunc (e *DomainError) Unwrap() error\n```\nUnwrap permite unwrapping del error original\n\n```go\nfunc (e *DomainError) WithCause(cause error) *DomainError\n```\nWithCause añade la causa del error\n\n```go\nfunc (e *DomainError) WithContext(ctx *ErrorContext) *DomainError\n```\nWithContext añade contexto al error\n\n```go\nfunc (e *DomainError) WithMetadata(key string, value interface{}) *DomainError\n```\nWithMetadata añade metadata al error\n\n```go\nfunc (e *DomainError) WithStackTrace(skip int) *DomainError\n```\nWithStackTrace añade stack trace al error\n\n```go\nfunc (e *DomainError) WithTags(tags ...string) *DomainError\n```\nWithTags añade tags para clasificación\n\n```go\ntype ErrorCategory string\n```\nErrorCategory define la categoría del error\n\n```go\nconst (\n\tCategoryValidation     ErrorCategory = \"validation\"\n\tCategoryBusiness       ErrorCategory = \"business\"\n\tCategoryTechnical      ErrorCategory = \"technical\"\n\tCategorySecurity       ErrorCategory = \"security\"\n\tCategoryIntegration    ErrorCategory = \"integration\"\n\tCategoryPerformance    ErrorCategory = \"performance\"\n\tCategoryInfrastructure ErrorCategory = \"infrastructure\"\n)\n```\n\n```go\ntype ErrorContext struct {\n\tService       string                 `json:\"service\"`\n\tVersion       string                 `json:\"version\"`\n\tRequestID     string                 `json:\"request_id\"`\n\tCorrelationID string                 `json:\"correlation_id\"`\n\tUserID        string                 `json:\"user_id,omitempty\"`\n\tTenantID      string                 `json:\"tenant_id,omitempty\"`\n\tSessionID     string                 `json:\"session_id,omitempty\"`\n\tTimestamp     time.Time              `json:\"timestamp\"`\n\tEnvironment   string                 `json:\"environment\"`\n\tMetadata      map[string]interface{} `json:\"metadata,omitempty\"`\n\tTraceID       string                 `json:\"trace_id,omitempty\"`\n\tSpanID        string                 `json:\"span_id,omitempty\"`\n}\n```\nErrorContext proporciona contexto rico para errores\n\n```go\ntype ErrorSeverity string\n```\nErrorSeverity define la severidad del error\n\n```go\nconst (\n\tSeverityLow      ErrorSeverity = \"low\"\n\tSeverityMedium   ErrorSeverity = \"medium\"\n\tSeverityHigh     ErrorSeverity = \"high\"\n\tSeverityCritical ErrorSeverity = \"critical\"\n)\n```\n\n```go\ntype HTTPError struct {\n\tCode          string                 `json:\"code\"`\n\tMessage       string                 `json:\"message\"`\n\tCategory      string                 `json:\"category\"`\n\tSeverity      string                 `json:\"severity\"`\n\tDetails       map[string]interface{} `json:\"details,omitempty\"`\n\tField         string                 `json:\"field,omitempty\"`\n\tValue         interface{}            `json:\"value,omitempty\"`\n\tRequestID     string                 `json:\"request_id,omitempty\"`\n\tCorrelationID string                 `json:\"correlation_id,omitempty\"`\n\tTraceID       string                 `json:\"trace_id,omitempty\"`\n\tTimestamp     time.Time              `json:\"timestamp\"`\n\tRetryable     bool                   `json:\"retryable\"`\n\tTransient     bool                   `json:\"transient\"`\n\tHelpURL       string                 `json:\"help_url,omitempty\"`\n}\n```\nHTTPError representa un error HTTP para respuestas API\n\n```go\ntype HTTPErrorResponse struct {\n\tError      HTTPError `json:\"error\"`\n\tStatusCode int       `json:\"-\"`\n}\n```\nHTTPErrorResponse representa la respuesta de error completa\n\n```go\ntype IntegrationError struct {\n\tService      string                 `json:\"service\"`\n\tEndpoint     string                 `json:\"endpoint,omitempty\"`\n\tMethod       string                 `json:\"method,omitempty\"`\n\tStatusCode   int                    `json:\"status_code,omitempty\"`\n\tResponse     string                 `json:\"response,omitempty\"`\n\tTimeout      bool                   `json:\"timeout\"`\n\tNetworkError bool                   `json:\"network_error\"`\n\tMetadata     map[string]interface{} `json:\"metadata,omitempty\"`\n}\n```\nIntegrationError representa un error de integración con servicios externos\n\n```go\ntype SecurityError struct {\n\tThreat      string     `json:\"threat\"`\n\tAction      string     `json:\"action\"`\n\tSeverity    string     `json:\"severity\"`\n\tRemoteIP    string     `json:\"remote_ip,omitempty\"`\n\tUserAgent   string     `json:\"user_agent,omitempty\"`\n\tBlockedTime *time.Time `json:\"blocked_until,omitempty\"`\n}\n```\nSecurityError representa un error de seguridad\n\n```go\ntype StackFrame struct {\n\tFunction string `json:\"function\"`\n\tFile     string `json:\"file\"`\n\tLine     int    `json:\"line\"`\n\tPackage  string `json:\"package\"`\n}\n```\nStackFrame representa un frame en el stack trace\n\n```go\ntype StackTrace struct {\n\tFrames []StackFrame `json:\"frames\"`\n\tRaw    string       `json:\"raw\"`\n}\n```\nStackTrace representa un stack trace completo\n\n```go\ntype ValidationError struct {\n\tField   string      `json:\"field\"`\n\tValue   interface{} `json:\"value\"`\n\tTag     string      `json:\"tag\"`\n\tMessage string      `json:\"message\"`\n}\n```\nValidationError representa un error de validación específico\n\n```go\ntype ValidationErrorResponse struct {\n\tError  HTTPError         `json:\"error\"`\n\tErrors []ValidationError `json:\"validation_errors\"`\n}\n```\nValidationErrorResponse representa una respuesta con múltiples errores de validación\n\n","path":"github.com/lukcba-developers/gopherkit/pkg/errors","name":"errors","synopsis":"","isRedistributable":true}
