better error message - #167
Conversation
|
Looks great let's update the colors to be more consistent: and we can remove the date near the bottom on this page |
| justify-content: center; | ||
| text-align: center; | ||
| padding: 2rem; | ||
| background-color: rgb(233, 236, 239); |
There was a problem hiding this comment.
This is already used as #e9ecef by .section-row and .syntax-view
Let's extract it into a variable to reuse
| and restarting the app. | ||
| </p> | ||
| <section class="friendly-error" role="alert" aria-live="assertive"> | ||
| <h1>Oops we couldn't process your request</h1> |
There was a problem hiding this comment.
nit: grammar
| <h1>Oops we couldn't process your request</h1> | |
| <h1>Oops, we couldn't process your request.</h1> |
| text-align: center; | ||
| padding: 2rem; | ||
| background-color: var(--dotnet-surface-subtle); | ||
| color: rgb(33, 37, 41); |
There was a problem hiding this comment.
Let's convert this to a hex value
| color: rgb(33, 37, 41); | |
| color: var(--dotnet-text-primary); |
| .layout-main:has(.friendly-error) + hr + .container-fluid[role="complementary"] { | ||
| display: none; | ||
| } | ||
|
|
||
| .layout-main:has(.friendly-error) { | ||
| background-color: var(--dotnet-surface-subtle); | ||
| } | ||
|
|
||
| .page-shell:has(.friendly-error) { | ||
| background-color: var(--dotnet-surface-subtle); | ||
| } | ||
|
|
||
| .layout-main:has(.friendly-error) + hr { | ||
| display: none; | ||
| } | ||
|
|
There was a problem hiding this comment.
Make the surface/text tokens theme-aware at :root rather than adding a second .friendly-error block inside a dark media query
| .layout-main:has(.friendly-error) + hr + .container-fluid[role="complementary"] { | |
| display: none; | |
| } | |
| .layout-main:has(.friendly-error) { | |
| background-color: var(--dotnet-surface-subtle); | |
| } | |
| .page-shell:has(.friendly-error) { | |
| background-color: var(--dotnet-surface-subtle); | |
| } | |
| .layout-main:has(.friendly-error) + hr { | |
| display: none; | |
| } | |
| .page-shell.is-error-page, | |
| .page-shell.is-error-page .layout-main { | |
| background-color: var(--dotnet-surface-subtle); | |
| } | |
| .page-shell.is-error-page hr, | |
| .page-shell.is-error-page .container-fluid[role="complementary"] { | |
| display: none; | |
| } | |
| display: block; | ||
| font-size: larger; | ||
| background-color: #e9ecef; | ||
| background-color: var(--dotnet-surface-subtle); |
There was a problem hiding this comment.
| background-color: var(--dotnet-surface-subtle); | |
| background-color: var(--dotnet-surface-code); |
There was a problem hiding this comment.
Delete redundant overrides
Now that .page-shell.is-error-page is in, these :has() rules are redundant. Note is-error-page isn't set anywhere yet, so this must land with the layout change in comment 3 or the error page loses its styling.
These are descendant selectors, so they'd hide every
This file isn't in the diff, so post as a general PR comment (or add the file to the PR first). is-error-page isn't applied anywhere in the repo — the only occurrences are in site.css. Wire it up:
The grammar fix from the earlier review was applied to Error.cshtml but not here:
Pages/Error.cshtml sets no layout, so it never renders .page-shell — neither the :has rules nor .is-error-page apply there. Only App.razor's ErrorBoundary path goes through MainLayout. Is the bare .friendly-error section sufficient styling for that page? |
| background-color: var(--dotnet-surface-subtle); | ||
| } | ||
|
|
||
| .page-shell.is-error-page > hr, |
There was a problem hiding this comment.
nit: indent
| .page-shell.is-error-page > hr, | |
| .page-shell.is-error-page > hr, |
danzhu54
left a comment
There was a problem hiding this comment.
The dark-mode a/a:link/a:visited override (lines 405–410) should be deleted but is still present.
The "redundant overrides" (originally ~lines 330–333, the .syntax-view .reference* block) should also be deleted.

This pull request improves error handling and user experience by providing a more user-friendly and consistent error message across the application. It introduces a custom error boundary for Blazor components, updates the error page and UI messages, and adds styling for the new error presentation.
Error handling and user experience improvements:
<ErrorBoundary>toApp.razorto catch unhandled exceptions in Blazor components, displaying a friendly error message within the main layout (src/apisof.net/App.razor). [1] [2]src/apisof.net/Pages/Error.cshtml).src/apisof.net/Pages/_Host.cshtml).Styling updates:
.friendly-errorclass and its heading to ensure consistent and prominent display of error messages (src/apisof.net/wwwroot/css/site.css).