Albatross.Exceptions 1.0.0

Prefix Reserved
dotnet add package Albatross.Exceptions --version 1.0.0
                    
NuGet\Install-Package Albatross.Exceptions -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Albatross.Exceptions" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Albatross.Exceptions" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Albatross.Exceptions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Albatross.Exceptions --version 1.0.0
                    
#r "nuget: Albatross.Exceptions, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Albatross.Exceptions@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Albatross.Exceptions&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Albatross.Exceptions&version=1.0.0
                    
Install as a Cake Tool

Albatross.Exceptions

A shared vocabulary of common semantic exception types. This assembly defines what error conditions are called, not what happens when they occur. Mapping exceptions to HTTP responses, CLI exit codes, or log levels is the responsibility of the hosting layer.

Albatross Exceptions

Exception Status Code Meaning
ValidationException 422 Input is structurally or semantically invalid and cannot be processed as-is.
NotAuthenticatedException 401 The caller's identity has not been established.
ForbiddenException 403 The caller is authenticated but lacks permission.
NotFoundException 404 A required entity or resource cannot be found.
ConflictException 409 The operation was attempted but conflicts with the current state of a resource.
PreconditionFailedException 412 The caller's explicitly stated precondition about resource state is not met.

Framework Exceptions

The following System exceptions are part of the same semantic vocabulary. They are not redefined in this assembly because the framework already provides them, but they should be used consistently and mapped by the hosting layer alongside the Albatross exceptions.

Exception Status Code Meaning
ArgumentException 400 An argument passed to a method is invalid. Use for method-contract violations at the API boundary. Prefer ValidationException for request-level input validation.
NotSupportedException 501 The operation is recognized but deliberately not supported. The system understands what was asked but will not do it.
TimeoutException 408 The operation exceeded its allotted time. Use when application code enforces a deadline, not for infrastructure-level timeouts handled by the framework.
OperationCanceledException - The operation was cancelled, typically via a CancellationToken. No HTTP response is expected — the request was abandoned by the caller.

Classifying exceptions

The SemanticError enum names every condition in both tables above as a value rather than a type. This is what lets a single category describe both the Albatross exceptions and the framework exceptions — a framework type can never implement an interface this assembly owns, but it can be mapped to an enum value.

TryGetSemanticError is the default classifier. It maps every exception in both tables to its SemanticError and returns false for anything it does not recognize:

if (exception.TryGetSemanticError(out var error)) {
    // map `error` to an HTTP status code, CLI exit code, or log level in the hosting layer
}

The hosting layer remains the owner of behavior. It may run its own ISemanticExceptionConverter chain first — to recognize transport- or library-specific exceptions — and fall back to TryGetSemanticError for the shared vocabulary.

Composing the converter and the classifier

ISemanticExceptionConverter and TryGetSemanticError form a two-stage pipeline:

arbitrary Exception ──ISemanticExceptionConverter──▶ semantic Exception ──TryGetSemanticError──▶ SemanticError
   (normalize)                                          (classify)
  • ISemanticExceptionConverter is the normalize stage. It turns exceptions outside the vocabulary — a library's DbException, a third-party client error, a domain-specific exception — into one of the known types.
  • TryGetSemanticError is the classify stage. It has no opinion about where an exception came from; it maps a known type to its SemanticError value.

The Resolve extension method wires them together — classify directly first, and only normalize when the exception is not already in the vocabulary:

public static SemanticError? Resolve(this Exception ex, params IEnumerable<ISemanticExceptionConverter> converters) {
    if (ex.TryGetSemanticError(out var error))          // already in the vocabulary?
        return error;
    foreach (var converter in converters) {             // otherwise try to normalize it
        if (converter.TryConvert(ex, out var converted) && converted.TryGetSemanticError(out error))
            return error;
    }
    return null;                                         // unknown — let it bubble as a 500
}

TryGetSemanticError already recognizes the four framework exceptions directly, so converters never need to handle those. Their job is strictly the exceptions that are not already in the shared vocabulary: the enum classifier owns the known set, and converters extend it.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Albatross.Exceptions:

Package Downloads
Albatross.Hosting

A library for creating .Net Web Api or Service applications with preconfigured settings

Albatross.EFCore

This assembly contains convenient classes that allow users to get EFCore up and running quickly. It also contains entity ChangeReporting functionality and implementation of DateLevelEntity pattern.

Albatross.Http

A companion library for HttpClient providing extensions and shared types for HTTP client code generation

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 206 6/27/2026