Skip to main content
The generator maps ErrorType enum values to HTTP status codes and BCL TypedResults types following RFC 9110 semantics.

ErrorType → HTTP Mapping

Failure and Unexpected both map to 500, not 422. These are server errors per RFC 9110. For 422, use Error.Custom(422, ...).

Success Type → HTTP Mapping

Custom Error Codes

Use Error.Custom() for status codes not covered by ErrorType:

Custom Error Resolution

ProblemDetails (RFC 7807)

All error responses use RFC 7807 ProblemDetails format:

Validation Errors

Multiple validation errors aggregate into HttpValidationProblemDetails:

Union Type Generation

The generator creates Results<...> union types for OpenAPI documentation:
When calling interface/abstract methods, the generator reads [ReturnsError] attributes to build the complete union. See Interface Types with ReturnsError.

BCL Limit

The BCL provides Results<T1, T2, ..., T6> - maximum 6 type parameters. When more types are needed:
  1. IResult fallback - Loses compile-time safety
  2. Consolidate errors - Use ProblemHttpResult for multiple codes
  3. Custom metadata - Implement IEndpointMetadataProvider

Type Deduplication

Failure and Unexpected both map to InternalServerError<ProblemDetails>, so only one appears in the union.

Type Ordering

Types are ordered by status code (ascending):

Middleware-Influenced Union Types

The generator adds status codes to the Results<...> union based on middleware attributes:
[AllowAnonymous] overrides [Authorize], so 401/403 are NOT added to the union. Similarly, [DisableRateLimiting] overrides [EnableRateLimiting], so 429 is NOT added.

Security Considerations

401 Unauthorized and 403 Forbidden return no body to prevent information leakage: