ErrorType enum values to HTTP status codes and BCL TypedResults types following RFC 9110 semantics.
ErrorType → HTTP Mapping
Success Type → HTTP Mapping
Custom Error Codes
UseError.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 intoHttpValidationProblemDetails:
Union Type Generation
The generator createsResults<...> 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 providesResults<T1, T2, ..., T6> - maximum 6 type parameters.
When more types are needed:
- IResult fallback - Loses compile-time safety
- Consolidate errors - Use
ProblemHttpResultfor multiple codes - 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 theResults<...> 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:
