Skip to main content

Imported from docs/reference/error-codes.md in cloud-factory. Last synced: 2026-03-15

Error Codes Reference

Cloud Factory uses a standardized error handling system based on RFC 7807 Problem Details. All error responses are returned with Content-Type: application/problem+json.

Error Response Format

{
  "type": "https://api.t-2.cloud/problems/entity-not-found",
  "title": "Entity Not Found",
  "status": 404,
  "detail": "Order not found: 123e4567-e89b-12d3-a456-426614174000",
  "instance": "/orders/123e4567-e89b-12d3-a456-426614174000",
  "code": "ENTITY_NOT_FOUND",
  "timestamp": "2026-03-15T10:30:00.000Z",
  "correlationId": "req-abc-123",
  "entityType": "Order",
  "entityId": "123e4567-e89b-12d3-a456-426614174000"
}

Standard Fields

FieldTypeAlways PresentDescription
typestringYesRFC 7807 problem type URI
titlestringYesShort human-readable title
statusnumberYesHTTP status code
detailstringYesDetailed error message
instancestringYesRequest path that generated the error
timestampstringYesISO 8601 timestamp
codestringFor DomainErrorsInternal error code
correlationIdstringIf providedFrom X-Correlation-Id header

Additional fields from the error's details object are spread into the response body.


Error Codes by Category

Validation Errors (HTTP 400)

CodeProblem Type URIDescriptionAdditional Fields
VALIDATION_ERROR/problems/validation-errorInput validation failedfieldErrors[]
INVALID_INPUT/problems/invalid-inputGeneral invalid input
INVALID_STATE_TRANSITION/problems/invalid-state-transitionCannot transition entity to target statecurrentState, targetState, entityType

Validation Error with Field Details

{
  "type": "https://api.t-2.cloud/problems/validation-error",
  "title": "Validation Error",
  "status": 400,
  "detail": "Validation failed",
  "fieldErrors": [
    {
      "field": "email",
      "code": "isEmail",
      "message": "email must be a valid email address"
    }
  ]
}

class-validator Errors

When NestJS class-validator pipe rejects input, errors are returned as:

{
  "type": "https://api.t-2.cloud/problems/http-400",
  "title": "Bad Request",
  "status": 400,
  "detail": "email must be an email; firstName should not be empty",
  "errors": ["email must be an email", "firstName should not be empty"]
}

Authentication Errors (HTTP 401)

CodeProblem Type URIDescription
AUTHENTICATION_ERROR/problems/authentication-errorGeneral authentication failure
INVALID_CREDENTIALS/problems/invalid-credentialsWrong email/password
TOKEN_EXPIRED/problems/token-expiredJWT access/refresh token expired
INVALID_TOKEN/problems/invalid-tokenMalformed or tampered token

Authorization Errors (HTTP 403)

CodeProblem Type URIDescriptionAdditional Fields
AUTHORIZATION_ERROR/problems/authorization-errorGeneral authorization failure
INSUFFICIENT_PERMISSIONS/problems/insufficient-permissionsMissing required permissionrequiredPermission
TENANT_ACCESS_DENIED/problems/tenant-access-deniedCannot access another tenant's datatenantId
RESOURCE_ACCESS_DENIED/problems/resource-access-deniedCannot access specific resourceresourceType, resourceId

Not Found Errors (HTTP 404)

CodeProblem Type URIDescriptionAdditional Fields
NOT_FOUND/problems/not-foundGeneric not found
ENTITY_NOT_FOUND/problems/entity-not-foundSpecific entity not foundentityType, entityId

Conflict Errors (HTTP 409)

CodeProblem Type URIDescriptionAdditional Fields
CONFLICT/problems/conflictGeneric conflict
DUPLICATE_ENTITY/problems/duplicate-entityEntity with identifier already existsentityType, identifier
CONCURRENCY_ERROR/problems/concurrency-errorOptimistic lock version mismatchentityType, entityId, expectedVersion
BUSINESS_RULE_VIOLATION/problems/business-rule-violationDomain rule prevents operationrule

Rate Limiting Errors (HTTP 429)

CodeProblem Type URIDescriptionAdditional Fields
RATE_LIMIT_EXCEEDED/problems/rate-limit-exceededToo many requestsretryAfterSeconds
QUOTA_EXCEEDED/problems/quota-exceededResource quota exceededquotaType, limit, current

Server Errors (HTTP 500/502/503)

CodeProblem Type URIHTTPDescriptionAdditional Fields
INTERNAL_ERROR/problems/internal-error500Unexpected server error
INTEGRATION_ERROR/problems/integration-error502External system failuresystem, cause
SERVICE_UNAVAILABLE/problems/service-unavailable503Service temporarily downservice

Domain-Specific Errors

CodeProblem Type URIHTTPDescriptionAdditional Fields
(dynamic)/problems/order-error400Order processing errororderId
(dynamic)/problems/provisioning-error500Provisioning pipeline errorrequestId, step
(dynamic)/problems/billing-integration-error502Billing/Stripe integration erroroperation
(dynamic)/problems/notification-error500Notification delivery errornotificationId
(dynamic)/problems/support-ticket-error400Ticket operation errorticketId

Domain-specific errors use dynamic codes set at instantiation (e.g., ORDER_ITEM_NOT_FOUND, PROVISIONING_TIMEOUT).


Error Class Hierarchy

Error
  └── DomainError (abstract)
        ├── ValidationError (400)
        ├── InvalidInputError (400)
        ├── InvalidStateTransitionError (400)
        ├── AuthenticationError (401)
        │   ├── InvalidCredentialsError
        │   ├── TokenExpiredError
        │   └── InvalidTokenError
        ├── AuthorizationError (403)
        │   ├── InsufficientPermissionsError
        │   ├── TenantAccessDeniedError
        │   └── ResourceAccessDeniedError
        ├── NotFoundError (404)
        │   └── EntityNotFoundError
        ├── ConflictError (409)
        │   ├── DuplicateEntityError
        │   ├── ConcurrencyError
        │   └── BusinessRuleViolationError
        ├── RateLimitExceededError (429)
        ├── QuotaExceededError (429)
        ├── InternalError (500)
        ├── IntegrationError (502)
        ├── ServiceUnavailableError (503)
        ├── OrderError (400)
        ├── ProvisioningError (500)
        ├── BillingIntegrationError (502)
        ├── NotificationError (500)
        └── SupportTicketError (400)

Fallback Behavior

When an error does not match a known DomainError code, the filter falls back to HTTP status-based problem types:

HTTP StatusFallback Type URIFallback Title
400/problems/http-400Bad Request
401/problems/http-401Unauthorized
403/problems/http-403Forbidden
404/problems/http-404Not Found
409/problems/http-409Conflict
429/problems/http-429Too Many Requests
500/problems/http-500Internal Server Error
502/problems/http-502Bad Gateway
503/problems/http-503Service Unavailable

Unhandled exceptions (non-DomainError, non-HttpException) always return:

{
  "type": "https://api.t-2.cloud/problems/http-500",
  "title": "Internal Server Error",
  "status": 500,
  "detail": "Internal server error"
}

Stack traces and internal details are never leaked to the client.


Source Files

  • Error classes: packages/common/src/errors/domain.errors.ts
  • Problem types: packages/common/src/errors/problem-types.ts
  • Exception filter: packages/common/src/infrastructure/filters/http-exception.filter.ts