Skip to main content

RA.Utilities.Core.Exceptions

NuGet version Codecov GitHub license NuGet Downloads

RA.Utilities.Core.Exceptions provides a set of standardized, semantic exceptions for use across the RA.Utilities ecosystem. These exceptions, such as NotFoundException and ConflictException, allow for clear, intent-driven error handling in your business logic.

🎯 Purpose

Instead of throwing generic Exception or ArgumentException types, this package provides exceptions that carry semantic meaning about what went wrong. This approach has several key benefits:

  • Clear Intent: Throwing a NotFoundException is more descriptive than a generic exception with a "not found" message.
  • Standardized Error Handling: Middleware (like in RA.Utilities.Api) can catch these specific exception types and automatically map them to the correct HTTP status codes and structured error responses (e.g., 404 Not Found, 409 Conflict).
  • Decoupled Logic: Your domain or application layer can focus on business rules and throw semantic exceptions without needing to know about HTTP details. The web layer handles the translation.
  • Reduced Boilerplate: Eliminates the need for repetitive try-catch blocks in your controllers for common error scenarios.

🛠️ Installation

You can install the package via the .NET CLI:

dotnet add package RA.Utilities.Core.Exceptions

Or through the NuGet Package Manager console:

Install-Package RA.Utilities.Core.Exceptions

Or through the NuGet Package Manager in Visual Studio.

✨ Available Exceptions