What problem does it solve?
Provides a clear, consistent strategy for handling both expected and unexpected failures in .NET APIs so clients always receive well-formed, predictable error responses and developers avoid using exceptions for normal control flow.
Core Features & Use Cases
- Result Pattern for Expected Failures: Return Result or Result<T> for business conditions like "not found" or validation failures instead of throwing exceptions.
- RFC 9457 ProblemDetails Responses: Map failures to ProblemDetails with type, title, status, detail, and optional errors for consistent API contracts.
- Global Exception Handling: Catch unexpected exceptions at the middleware layer, log structured errors, and return safe ProblemDetails in production.
- Validation Integration: Use FluentValidation with endpoint filters to validate requests at the API boundary and return typed validation ProblemDetails.
- Typed Errors and Mapping: Define error records or enums and map them to appropriate HTTP status codes for richer client behavior.
- Use Case: Implementing a REST or minimal API where orders, payments, and third-party failures must surface predictable, localized error payloads without leaking internal details.
Quick Start
Use this skill to map your Result<T> failures to RFC 9457 ProblemDetails, register a global exception handler, and add a FluentValidation endpoint filter so your API returns consistent structured errors.