diff --git a/src/cli/index.js b/src/cli/index.js index be15e3b79..2d3c20d70 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -1,5 +1,6 @@ "use strict"; +const _ = require("lodash"); const { Command } = require("@gemini-testing/commander"); const escapeRe = require("escape-string-regexp"); @@ -23,9 +24,11 @@ process.on("unhandledRejection", (reason, p) => { return; } - const error = `Unhandled Rejection in hermione:master:${process.pid}:\nPromise: ${JSON.stringify( - p, - )}\nReason: ${reason}`; + const error = [ + `Unhandled Rejection in hermione:master:${process.pid}:`, + `Promise: ${JSON.stringify(p)}`, + `Reason: ${_.get(reason, "stack", reason)}`, + ].join("\n"); if (hermione) { hermione.halt(error); diff --git a/src/utils/processor.js b/src/utils/processor.js index 3594eb00b..28c36fa1d 100644 --- a/src/utils/processor.js +++ b/src/utils/processor.js @@ -11,9 +11,11 @@ process.on("unhandledRejection", (reason, p) => { return; } - const error = `Unhandled Rejection in hermione:worker:${process.pid}:\nPromise: ${JSON.stringify( - p, - )}\nReason: ${reason}`; + const error = [ + `Unhandled Rejection in hermione:worker:${process.pid}:`, + `Promise: ${JSON.stringify(p)}`, + `Reason: ${_.get(reason, "stack", reason)}`, + ].join("\n"); ipc.emit(WORKER_UNHANDLED_REJECTION, { error }); });