---
title: SAIFException
summary: API reference for SAIFException.
status: draft
owner: andmil
last_reviewed: 2026-09-15
library: SAIF.Web.API.Core
reference_type: package
---

# SAIFException

`SAIFException` is the abstract base type for every API exception defined in this library. It adds a single capability beyond the standard .NET `Exception`: a settable `HttpStatusCode` property, so that HTTP-facing consumers can associate and later read an HTTP status on the exception instance ([BR-CORE-002](../../business-rules.md#br-core-002-httpstatuscode-carried-by-every-saifexception-subtype)). This library supplies only the vocabulary/types for HTTP-failure signaling — the decision of which status maps to which concrete subtype is made by the consumer, e.g. `SAIF.Web.API.Clients`'s `ExceptionHandler.ToKnownError`, not by this class.

## Purpose
- Serve as the common base for `NoMatchingDataException`, `UnauthorizedAccessException`, `InternalServerError`, and `InvalidDataException`, so consumers can catch `SAIFException` to handle any API-originated error uniformly.
- Carry a settable `HttpStatusCode`, distinct from the exception's own identity, so that HTTP-facing consumers can set/read the status after construction ([BR-CORE-002](../../business-rules.md#br-core-002-httpstatuscode-carried-by-every-saifexception-subtype)).

## Context
- Namespace: `SAIF.API.Exceptions`
- Assembly/package: `SAIF.Web.API.Core` (bundled into the `SAIF.Web.API.Clients` NuGet package)

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `SAIFException()` | `SAIFException()` | Parameterless constructor; forwards to the base `Exception()` constructor with no message. |
| `SAIFException(string message)` | `SAIFException(string message)` | Constructs the exception with the given message. |
| `SAIFException(string message, Exception innerException)` | `SAIFException(string message, Exception innerException)` | Constructs the exception with a message and a wrapped inner exception. |
| `SAIFException(SerializationInfo info, StreamingContext context)` | `SAIFException(SerializationInfo info, StreamingContext context)` | Standard .NET exception deserialization constructor. |
| `HttpStatusCode` | `HttpStatusCode HttpStatusCode { get; set; }` | Associates an HTTP status code with the exception instance; no constructor in this class assigns a default value — it is set by the consumer after construction ([BR-CORE-002](../../business-rules.md#br-core-002-httpstatuscode-carried-by-every-saifexception-subtype)). |

## Behavioral notes
- `SAIFException` is `abstract`; it cannot be instantiated directly and exists only to be subclassed.
- No constructor sets `HttpStatusCode` — it must be assigned by the consumer after construction, per its plain property declaration.

## Constraints and usage notes
- All four concrete subtypes defined in this library (`NoMatchingDataException`, `UnauthorizedAccessException`, `InternalServerError`, `InvalidDataException`) are public and concrete, with no further subclasses defined within this library.

## Sources
- `src/SAIF.Web.API.Core/SAIFException.cs`
