Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}

Comment on lines 159 to +165
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errorMessages is declared as string[] but initialized with the raw caught error value. Since catch can receive non-Error values (and callers pass unknown), this can produce unhelpful output like [object Object] and makes the array content inconsistent. Consider stringifying the top-level error explicitly (e.g., prefer error.message/String(error)), then optionally append stack traces.

Copilot uses AI. Check for mistakes.
// 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
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inner forEach callback parameter is still named error, which shadows the outer error parameter and contradicts the intent described in the PR. Rename the inner variable (e.g., innerError) to avoid confusion and make it clear which error’s stack/message is being logged.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines 160 to +172
Copy link

Copilot AI Mar 30, 2026

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.

Suggested change
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}`)

Copilot uses AI. Check for mistakes.
}
})
}

Expand Down
Loading