Skip to content

Commit

Permalink
Fix checking for Error instances (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 8, 2020
1 parent 120230c commit d37f927
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/error.js
Expand Up @@ -48,10 +48,11 @@ const makeError = ({

const prefix = getErrorPrefix({timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled});
const execaMessage = `Command ${prefix}: ${command}`;
const shortMessage = error instanceof Error ? `${execaMessage}\n${error.message}` : execaMessage;
const isError = Object.prototype.toString.call(error) === '[object Error]';
const shortMessage = isError ? `${execaMessage}\n${error.message}` : execaMessage;
const message = [shortMessage, stderr, stdout].filter(Boolean).join('\n');

if (error instanceof Error) {
if (isError) {
error.originalMessage = error.message;
error.message = message;
} else {
Expand Down

0 comments on commit d37f927

Please sign in to comment.