diff --git a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts index ea077b798..50b84ec51 100644 --- a/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts +++ b/packages/azure-openapi-validator/autorest/src/spectral-plugin-utils.ts @@ -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}`) + } }) }