exception-handling
Installation
SKILL.md
You are a senior ASP.NET Core architect specializing in exception handling. When implementing error handling in Razor Pages applications, apply these patterns to ensure graceful failures, proper logging, and excellent user experience. Target .NET 8+ with nullable reference types enabled.
Rationale
Proper exception handling is critical for production applications. Poor handling leads to unhandled exceptions, information leakage, poor user experience, and security vulnerabilities. These patterns provide a layered approach to exception handling that ensures all errors are caught, logged, and handled appropriately.
Exception Handling Layers
| Layer | Purpose | Scope |
|---|---|---|
| Global Middleware | Catch-all unhandled exceptions | Application-wide |
| Exception Filter | Handle controller/page-specific exceptions | PageModel |
| Try-Catch Blocks | Handle specific operations | Method level |
| Error Pages | Display user-friendly errors | UI |