-
Notifications
You must be signed in to change notification settings - Fork 51
Include stack traces in catchSpectralRunErrors for improved debugging #845
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
9b70364
b849841
1cb8545
d678227
4a8564b
f113f34
c8ee673
1fc600e
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -159,11 +159,18 @@ export function catchSpectralRunErrors(file: string, error: any, initiator: IAut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Initialize an array to collect error messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const errorMessages: string[] = [error] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (error && error.stack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| errorMessages.push(`Stack:\n${error.stack}`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check if "error" contains the "errors" property | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (error && error.errors && Array.isArray(error.errors)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error.errors.forEach((error: any, index: number) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Push each error message into the array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| errorMessages.push(`Error ${index + 1}: ${error.message}`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (error.stack) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| errorMessages.push(`Stack ${index + 1}:\n${error.stack}`) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
168
to
+172
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error.errors.forEach((error: any, index: number) => { | |
| // Push each error message into the array | |
| errorMessages.push(`Error ${index + 1}: ${error.message}`) | |
| if (error.stack) { | |
| errorMessages.push(`Stack ${index + 1}:\n${error.stack}`) | |
| error.errors.forEach((innerError: any, index: number) => { | |
| // Push each error message into the array | |
| errorMessages.push(`Error ${index + 1}: ${innerError.message}`) | |
| if (innerError.stack) { | |
| errorMessages.push(`Stack ${index + 1}:\n${innerError.stack}`) |
Copilot
AI
Mar 30, 2026
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.
When formatting constituent AggregateError entries, the code assumes each item has message (and now stack). Since AggregateError.errors can contain arbitrary values, error.message may be undefined and degrade the output. Consider falling back to String(error) when message is missing, and only include a stack trace when it’s a string.
| const errorMessages: string[] = [error] | |
| if (error && error.stack) { | |
| errorMessages.push(`Stack:\n${error.stack}`) | |
| } | |
| // Check if "error" contains the "errors" property | |
| if (error && error.errors && Array.isArray(error.errors)) { | |
| error.errors.forEach((error: any, index: number) => { | |
| // Push each error message into the array | |
| errorMessages.push(`Error ${index + 1}: ${error.message}`) | |
| if (error.stack) { | |
| errorMessages.push(`Stack ${index + 1}:\n${error.stack}`) | |
| const errorMessages: string[] = [] | |
| // Top-level error message (fall back to String(error) if no .message) | |
| const topLevelMessage = | |
| error && typeof error === "object" && typeof (error as any).message === "string" | |
| ? (error as any).message | |
| : String(error) | |
| errorMessages.push(topLevelMessage) | |
| // Top-level stack trace (include only if it's a string) | |
| if (error && typeof (error as any).stack === "string") { | |
| errorMessages.push(`Stack:\n${(error as any).stack}`) | |
| } | |
| // Check if "error" contains the "errors" property (AggregateError) | |
| if (error && Array.isArray((error as any).errors)) { | |
| ;(error as any).errors.forEach((innerError: any, index: number) => { | |
| // Derive each constituent error message with a safe fallback | |
| const innerMessage = | |
| innerError && typeof innerError === "object" && typeof innerError.message === "string" | |
| ? innerError.message | |
| : String(innerError) | |
| errorMessages.push(`Error ${index + 1}: ${innerMessage}`) | |
| // Include stack trace only when it's a string | |
| if (innerError && typeof innerError.stack === "string") { | |
| errorMessages.push(`Stack ${index + 1}:\n${innerError.stack}`) |
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.
errorMessagesis declared asstring[]but initialized with the raw caughterrorvalue. Sincecatchcan receive non-Error values (and callers passunknown), this can produce unhelpful output like[object Object]and makes the array content inconsistent. Consider stringifying the top-level error explicitly (e.g., prefererror.message/String(error)), then optionally append stack traces.