Skip to content

feat: allow smuggeling an exception in a ProblemInstance - #557

Merged
Alxandr merged 1 commit into
mainfrom
feat/problem-source
Apr 24, 2026
Merged

feat: allow smuggeling an exception in a ProblemInstance#557
Alxandr merged 1 commit into
mainfrom
feat/problem-source

Conversation

@Alxandr

@Alxandr Alxandr commented Apr 24, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-carrying ProblemInstance.Create(...) (and ProblemDescriptor.Create(...)) overloads, plus ProblemInstance.ToException() / Throw() helpers.
  • Update ProblemInstanceException to fall back to the ProblemInstance-carried exception as InnerException.
  • 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
@Alxandr
Alxandr force-pushed the feat/problem-source branch from 6fd0bb7 to a9c94a3 Compare April 24, 2026 12:01
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
57.9% Coverage on New Code (required ≥ 65%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants