-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Addon Vitest: Improve error message in testing widget modal #33481
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,7 @@ export function errorToErrorLike(error: Error): ErrorLike { | |||||
| message: error.message, | ||||||
| name: error.name, | ||||||
| // avoid duplicating the error message in the stack trace | ||||||
| stack: error.stack?.replace(error.message, ''), | ||||||
| stack: error.message + ' ' + error.stack?.replace(error.message, ''), | ||||||
|
Contributor
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. Handle undefined If 🐛 Proposed fix- stack: error.message + ' ' + error.stack?.replace(error.message, ''),
+ stack: error.stack ? `${error.message}\n${error.stack.replace(error.message, '')}` : error.message,This ensures:
📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Member
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. Doesn't the So would this code cause the error.message to be in the string twice, but only get replaced once?
Member
Author
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. The bug here is that the stack did not contain the error message and the actual message was never visible to the user which is bad. In the unlikely chance that there's an error message in the stack, it will get replaced and therefore you will only ever see the error message once. |
||||||
| cause: error.cause && error.cause instanceof Error ? errorToErrorLike(error.cause) : 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.
Update the misleading comment.
The comment states "avoid duplicating the error message" but the code on line 8 now explicitly prepends the error message to the stack. Update the comment to reflect the actual intent, such as "ensure the error message is included in the stack trace."
📝 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents