feat: Add an accordion to the unknown error page that lets the user see information about the error#4210
Conversation
📝 WalkthroughWalkthroughThis PR refactors UnknownError to accept and display an Error/AxiosError via a new UnknownErrorDetails component (accordion, location/time, optional response status, stacktrace, copy-to-clipboard). Error objects are propagated from multiple handlers, localization keys added, and tests updated to exercise the details UI. ChangesError Detail Display Enhancement
🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/features/instantiate/containers/UnknownErrorDetails.tsx`:
- Around line 31-45: In handleCopyErrorClicked, awaiting
navigator.clipboard.writeText and handling rejection is required so
setCopied(true) only runs on successful write; update the function to await the
Promise returned by navigator.clipboard.writeText(JSON.stringify(errorInfo,
null, 2)), wrap it in try/catch, call setCopied(true) inside the try block on
success, and in the catch block clear or set an error flag (e.g.,
setCopied(false) or setCopyError) and optionally log the error so
denied/insecure-context failures don’t show a successful copy state.
In `@src/features/instantiate/InstantiationError.tsx`:
- Line 23: The current return in InstantiationError creates a new synthetic
Error and discards the original `error`, losing diagnostics; instead pass the
original `error` through to the UnknownError component (use UnknownError's
`error` prop) so the original Axios/stack details are preserved — if `error` may
not be an Error instance, wrap it in a new Error but retain the original as the
cause or a property (e.g., include `cause` or `originalError`) so full
diagnostics remain available.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bc2da5e0-4ff1-4f8e-b979-f7c2de4cf3bc
📒 Files selected for processing (13)
src/components/altinnError.tsxsrc/core/errorHandling/DisplayError.tsxsrc/features/instantiate/InstantiationError.tsxsrc/features/instantiate/containers/InstantiateContainer.tsxsrc/features/instantiate/containers/UnknownError.module.csssrc/features/instantiate/containers/UnknownError.test.tsxsrc/features/instantiate/containers/UnknownError.tsxsrc/features/instantiate/containers/UnknownErrorDetails.module.csssrc/features/instantiate/containers/UnknownErrorDetails.tsxsrc/language/texts/en.tssrc/language/texts/nb.tssrc/language/texts/nn.tssrc/layout/SigningActions/PanelAwaitingCurrentUserSignature.tsx
|
/publish |
PR release:
|
|
|
✅ Automatic backport successful! A backport PR has been automatically created for the The release branch The cherry-pick was clean with no conflicts. Please review the backport PR when it appears. |
…ee information about the error (#4210) * Create a unknown error details component * clean up css * Add copied feedback * add translations * Add error to usages of UnknownError * Add unit test * add comment about availability of clipboard * Add error when using UknownError from InstantiateContainer * await and try-catch clipboard.writeText * Delete InstantiationError since its not in use * Fix tests * improve test



Description
On the error page, there were noe information about the error, making it very hard to debug. This PR adds information to make such errors easier to debug. T
Initial view for the user after changes in this PR:

After the user have expanded the deails :

Details
The information is hidden by default with an Accordion to not overwhelm the user with technical details.
When the information is expanded, we show :
A button to copy the details to the clipboard is also added. This makes it easier for the user to copy all the information we need for debugging and send it to us.
A required error-property has been added to the UnknownError-component. This ensures that we always have some information to show.
The UnknownError-component was used in src/features/instantiate/InstantiationError.tsx, but it seems that Component was never used, so I removed it.
Related Issue(s)
Verification/QA
kind/*andbackport*label to this PR for proper release notes groupingSummary by CodeRabbit
New Features
Bug Fixes
Localization
Tests