Skip to content

Commit

Permalink
preserve pnpm stack-trace when re-throwing from bit (#7889)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfirst authored Sep 8, 2023
1 parent 9f444f9 commit a077fd8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion scopes/dependencies/pnpm/pnpm-error-to-bit-error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export class BitErrorWithRichMessage extends BitError {
}

export function pnpmErrorToBitError(err: PnpmError): BitError {
return new BitErrorWithRichMessage(err.message, renderErrorMessage(err));
const newErr = new BitErrorWithRichMessage(err.message, renderErrorMessage(err));
newErr.cause = err;
return newErr;
}

function renderErrorMessage(err: PnpmError): string {
Expand Down
3 changes: 1 addition & 2 deletions src/cli/handle-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import loader from './loader';
export async function handleErrorAndExit(err: Error, commandName: string, shouldSerialize = false): Promise<void> {
try {
loader.off();
logger.error(`got an error from command ${commandName}: ${err}`);
logger.error(err.stack || '<no error stack was found>');
logger.error(`got an error from command ${commandName}: ${err}`, err);
const { message, error } = defaultHandleError(err);
if (shouldSerialize) serializeErrAndExit(error, commandName);
else await logErrAndExit(message, commandName);
Expand Down

0 comments on commit a077fd8

Please sign in to comment.