-
Notifications
You must be signed in to change notification settings - Fork 109
[web-console] Improve error popups by including error context #5868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| import { toast } from 'svelte-french-toast' | ||
|
|
||
| export const useToast = () => { | ||
| const toastError = (error: Error, durationMs?: number) => { | ||
| const showToastError = (scope: string, error: Error, durationMs?: number) => { | ||
| try { | ||
| toast.error(error.message, { | ||
| const message = scope ? `${scope}: ${error.message}` : error.message | ||
| toast.error(message, { | ||
| className: 'text-lg !max-w-[500px] whitespace-pre-wrap', | ||
| duration: durationMs | ||
| }) | ||
|
|
@@ -12,16 +13,23 @@ export const useToast = () => { | |
| console.log('Original error: ', error) | ||
| } | ||
| } | ||
| const toastError = (scope: string) => (error: Error, durationMs?: number) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the Please add Vitest unit tests for at minimum:
Pure functions, no DOM needed. Setup: |
||
| showToastError(scope, error, durationMs) | ||
| } | ||
| return { | ||
| toastError, | ||
| catchError<Args extends any[], R>(f: (...args: Args) => R, durationMs?: number) { | ||
| catchError<Args extends any[], R>( | ||
| scope: string, | ||
| f: (...args: Args) => R, | ||
| durationMs?: number | ||
| ) { | ||
| return (...args: Args) => { | ||
| try { | ||
| return f(...args) | ||
| } catch (e) { | ||
| if (e instanceof Error) { | ||
| requestAnimationFrame(() => { | ||
| toastError(e, durationMs) | ||
| showToastError(scope, e, durationMs) | ||
| }) | ||
| } | ||
| return undefined | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Behavior change: the old
getAction: (alt) => (alt ? 'start_paused' : 'start')let users Ctrl/Shift/Meta-click to launch without pausing. That shortcut is gone now —_start_pausedalways firesstart_paused. Intentional?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's intended simplification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough — intentional removal noted. The test gap is still the open blocker though (the curried
toastErrorand the simplified start action need coverage).