feat: allow smuggeling an exception in a ProblemInstance - #557
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Altinn.Authorization.ProblemDetails abstractions to allow attaching an Exception to a ProblemInstance while keeping ProblemInstance equality/hash semantics unchanged, and provides convenience APIs for converting/throwing problem instances as exceptions.
Changes:
- Add
Exception-carryingProblemInstance.Create(...)(andProblemDescriptor.Create(...)) overloads, plusProblemInstance.ToException()/Throw()helpers. - Update
ProblemInstanceExceptionto fall back to theProblemInstance-carried exception asInnerException. - Introduce
EqualityIgnoredOptional<T>so the attached exception is excluded from record equality/hash, and add a unit test verifying exception is ignored in equality.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Altinn.Authorization.ProblemDetails/test/ProblemDetails.Tests/ProblemInstanceTests.cs | Adds a regression test that ProblemInstance equality/hash ignore the attached exception. |
| src/Altinn.Authorization.ProblemDetails/src/ProblemDetails.Abstractions/ProblemInstance.cs | Adds exception-carrying factory overloads and stores exception in an equality-ignored wrapper. |
| src/Altinn.Authorization.ProblemDetails/src/ProblemDetails.Abstractions/EqualityIgnoredOptional.cs | New helper type used to exclude exception from record equality/hash. |
| src/Altinn.Authorization.ProblemDetails/src/ProblemDetails.Abstractions/ProblemInstanceException.cs | Uses problemInstance.Exception as InnerException fallback. |
| src/Altinn.Authorization.ProblemDetails/src/ProblemDetails.Abstractions/ProblemExtensions.cs | Adds Create(..., Exception) overloads and ProblemInstance extension members for ToException()/Throw(). |
| src/Altinn.Authorization.ProblemDetails/src/ProblemDetails.Abstractions/ValidationProblemInstance.cs | Updates base constructor call to pass exception: null. |
| src/Altinn.Authorization.ProblemDetails/src/ProblemDetails.Abstractions/MultipleProblemInstance.cs | Updates base constructor call to pass exception: null. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0950082 to
6fd0bb7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The smuggeled exception is used when converting the ProblemInstance to an Exception
6fd0bb7 to
a9c94a3
Compare
|


No description provided.