Construct InvalidDataException from validation failures¶
This constructor is the one exception-hierarchy member with conditional/multi-step logic worth documenting as an operation in its own right: it builds an InvalidDataException whose Message is the semicolon-joined set of the supplied failures' ErrorMessage values, and whose ValidationErrors list holds all supplied failures (BR-CORE-001).
| Field | Value |
|---|---|
| Operation ID | OP-CORE-002 |
| Trigger | A consumer constructs InvalidDataException with a collection of ValidationFailure objects |
| Inputs | IEnumerable<ValidationFailure> failures |
| Outputs | A constructed InvalidDataException with Message and ValidationErrors populated |
| Primary components | SAIF.API.Exceptions.InvalidDataException(IEnumerable<ValidationFailure>) |
| Entry point | src/SAIF.Web.API.Core/SAIFException.cs |
Steps¶
- Project
failuresto theirErrorMessagestrings via LINQ.Select(x => x.ErrorMessage). No business rule; no SQL. - Join the projected messages using the
ToStringAll(";")extension method (a member ofSAIF.Common.Extensions, supplied by a referenced assembly rather than by this project, and presumed to originate from the internal-organizationSAIF.Framework.CommonNuGet package**) and pass the joined string to the baseException(string message)constructor (BR-CORE-001). - The join implementation itself was not traced beyond its call site — its defining assembly was not accessible to local source analysis and was not independently retrieved via the Legends CLI RAG service in this pass**.
- Materialize
failuresto aList<ValidationFailure>and assign it toValidationErrors(BR-CORE-001).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start(["InvalidDataException<br>constructed with<br>failures"]) --> Project["Project failures to<br>ErrorMessage strings"]
Project --> Join["Join messages via<br>ToStringAll<br>semicolon-delimited"]
Join --> Base["Pass joined string to<br>base Exception<br>constructor"]
Base --> Assign["Materialize failures to<br>list, assign to<br>ValidationErrors"]
Assign --> Done([Exception constructed])
Failure and edge-case behavior¶
- For an empty
failurescollection, the constructor still projects the (empty) sequence and passes it toToStringAll(";"); the resulting message is unknown, since theToStringAllimplementation was not traced or independently retrieved**. - The
ToStringAlljoin implementation itself was not traced, sinceSAIF.Common.Extensionsis defined outside this repository's scanned source.
Related documentation¶
Note: Statements marked with
**could not be confirmed; treat as unknown until verified.
Sources¶
src/SAIF.Web.API.Core/SAIFException.cs