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

# InvalidDataException

`SAIF.API.Exceptions.InvalidDataException` is a concrete `SAIFException` subtype signaling invalid request data, with a fixed default message of `"Error: Invalid data in request."` when constructed with no arguments ([BR-CORE-003](../../business-rules.md#br-core-003-fixed-default-exception-messages)). Unlike the other three concrete subtypes, it also carries a `ValidationErrors` list of per-field `ValidationFailure` details, populated only via its `ValidationFailure`/`IEnumerable<ValidationFailure>` constructors ([BR-CORE-001](../../business-rules.md#br-core-001-invaliddataexception-validation-failure-projection); see [Construct InvalidDataException from validation failures](../../operations/construct-invaliddataexception-from-validation-failures.md)). It is thrown by [SAIF.Web.API.Clients](../../../saif-web-api-clients/overview.md)'s `ExceptionHandler.ToKnownError` when an HTTP `400` response is received.

## Purpose
- Provide a strongly-typed "invalid request data" signal for consumers, in place of raw `400` status handling ([BR-CORE-003](../../business-rules.md#br-core-003-fixed-default-exception-messages)).
- Expose the individual `ValidationFailure` records behind an invalid-data response via `ValidationErrors`, so a consumer (per source comment, potentially an ASP.NET MVC application's `ModelState`) can surface field-level validation detail rather than only a single joined message ([BR-CORE-001](../../business-rules.md#br-core-001-invaliddataexception-validation-failure-projection)).

## 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 |
| --- | --- | --- |
| `ValidationErrors` | `IList<ValidationFailure> ValidationErrors { get; }` | Get-only list of the validation failures behind this exception; populated only via the `ValidationFailure`/`IEnumerable<ValidationFailure>` constructors — remains unset (`null`) for the other constructors ([BR-CORE-001](../../business-rules.md#br-core-001-invaliddataexception-validation-failure-projection)). |
| `InvalidDataException()` | `InvalidDataException()` | Constructs the exception with the fixed default message `"Error: Invalid data in request."` ([BR-CORE-003](../../business-rules.md#br-core-003-fixed-default-exception-messages)). `ValidationErrors` is left unset. |
| `InvalidDataException(string message)` | `InvalidDataException(string message)` | Constructs the exception with a caller-supplied message. `ValidationErrors` is left unset. |
| `InvalidDataException(string message, Exception innerException)` | `InvalidDataException(string message, Exception innerException)` | Constructs the exception with a caller-supplied message and a wrapped inner exception. `ValidationErrors` is left unset. |
| `InvalidDataException(SerializationInfo info, StreamingContext context)` | `InvalidDataException(SerializationInfo info, StreamingContext context)` | Standard .NET exception deserialization constructor. `ValidationErrors` is left unset. |
| `InvalidDataException(ValidationFailure failure)` | `InvalidDataException(ValidationFailure failure)` | Constructs the exception with `Message` set to `failure.ErrorMessage` and `ValidationErrors` set to a single-item list containing `failure` ([BR-CORE-001](../../business-rules.md#br-core-001-invaliddataexception-validation-failure-projection)). |
| `InvalidDataException(IEnumerable<ValidationFailure> failures)` | `InvalidDataException(IEnumerable<ValidationFailure> failures)` | Constructs the exception with `Message` set to the semicolon-joined `ErrorMessage` values of `failures` and `ValidationErrors` set to the materialized list of `failures` ([BR-CORE-001](../../business-rules.md#br-core-001-invaliddataexception-validation-failure-projection)). See [Construct InvalidDataException from validation failures](../../operations/construct-invaliddataexception-from-validation-failures.md) for the full step sequence. |

## Inherited public members

Members in this section are inherited from `SAIFException` in `SAIF.Web.API.Core`. They are available on this type through inheritance.

| Member | Signature | Purpose | Origin |
| --- | --- | --- | --- |
| `HttpStatusCode` | `HttpStatusCode HttpStatusCode { get; set; }` | Associates an HTTP status code with this exception instance; not set by any constructor in this library — assigned by the consumer after construction ([BR-CORE-002](../../business-rules.md#br-core-002-httpstatuscode-carried-by-every-saifexception-subtype)). | `SAIF.Web.API.Core` — `SAIFException` |

## Behavioral notes
- `ValidationFailure` is not defined in this repository; its shape beyond the `ErrorMessage` member (used via projection in the multi-failure constructor) could not be confirmed**.
- The `ValidationFailure`/`IEnumerable<ValidationFailure>` constructors are the only paths that populate `ValidationErrors`; all other constructors leave it unset (`null`).

## Constraints and usage notes
- No `sealed` keyword is present on this type, but it is not subclassed within this library.
- The multi-failure constructor delegates its message-joining to the external `ToStringAll(";")` extension method, whose implementation was not traced in this analysis (see [Construct InvalidDataException from validation failures](../../operations/construct-invaliddataexception-from-validation-failures.md))**.

> **Note:** Statements marked with `**` could not be confirmed; treat as unknown until verified.

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