Problem Details Integration

RFC 7807 Compliance

Property Type Description
StatusCode int HTTP status code for this error type
Title string? Short human-readable summary (RFC 7807 title)
Type string? RFC 7807 type URI identifying the error class
IncludeTags bool Include the error's .Tags dict in ProblemDetails.Extensions (default: false)
[MapToProblemDetails(StatusCode = 404, Title = "User Not Found")]
public class UserNotFoundError : Error
{
    public int UserId { get; }
    public UserNotFoundError(int userId) : base($"User {userId} not found")
    {
        UserId = userId;
        this.WithTag("UserId", userId);
    }
}

// Automatically generates:
{
    "type": "https://httpstatuses.com/404",
    "title": "User Not Found",
    "status": 404,
    "userId": 123
}

Use Type and IncludeTags for richer RFC 7807 responses:

[MapToProblemDetails(
    StatusCode = 404,
    Title = "User Not Found",
    Type = "https://api.example.com/errors/user-not-found",  // RFC 7807 type URI
    IncludeTags = true)]  // adds Tags dict to ProblemDetails.Extensions
public class UserNotFoundError : Error
{
    public UserNotFoundError(int userId) : base($"User {userId} not found")
        => this.WithTag("UserId", userId).WithTag("Resource", "User");
}

// Response with Type + IncludeTags:
{
    "type": "https://api.example.com/errors/user-not-found",
    "title": "User Not Found",
    "status": 404,
    "extensions": {
        "UserId": 42,
        "Resource": "User"
    }
}