Smart HTTP Mapping

Domain Error-Aware Status Code Detection (v1.20.0)

The ToIResult() family reads the HttpStatusCode tag from domain errors for accurate HTTP mapping:

Domain Error HTTP Status IResult
NotFoundError 404 Results.NotFound(message)
ValidationError 422 Results.Problem(detail, statusCode: 422)
ConflictError 409 Results.Conflict(message)
UnauthorizedError 401 Results.Unauthorized()
ForbiddenError 403 Results.Forbid()
No tag / generic Error 400 Results.Problem(detail, statusCode: 400)
// Domain errors automatically map to correct HTTP status codes
var result = Result<User>.Fail(new NotFoundError("User", 42));
return result.ToIResult(); // → 404 Not Found (reads HttpStatusCode tag)