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). 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; see Construct InvalidDataException from validation failures). It is thrown by SAIF.Web.API.Clients'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
400status handling (BR-CORE-003). - Expose the individual
ValidationFailurerecords behind an invalid-data response viaValidationErrors, so a consumer (per source comment, potentially an ASP.NET MVC application'sModelState) can surface field-level validation detail rather than only a single joined message (BR-CORE-001).
Context¶
- Namespace:
SAIF.API.Exceptions - Assembly/package:
SAIF.Web.API.Core(bundled into theSAIF.Web.API.ClientsNuGet 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). |
InvalidDataException() |
InvalidDataException() |
Constructs the exception with the fixed default message "Error: Invalid data in request." (BR-CORE-003). 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). |
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). See Construct InvalidDataException from validation failures 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). | SAIF.Web.API.Core — SAIFException |
Behavioral notes¶
ValidationFailureis not defined in this repository; its shape beyond theErrorMessagemember (used via projection in the multi-failure constructor) could not be confirmed**.- The
ValidationFailure/IEnumerable<ValidationFailure>constructors are the only paths that populateValidationErrors; all other constructors leave it unset (null).
Constraints and usage notes¶
- No
sealedkeyword 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)**.
Note: Statements marked with
**could not be confirmed; treat as unknown until verified.
Sources¶
src/SAIF.Web.API.Core/SAIFException.cssrc/SAIF.Web.API.Clients/ExceptionHandler.cs