Skip to content

Commit

Permalink
Always print stack traces on exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinhagemeister committed Mar 27, 2021
1 parent 0db05e5 commit b3ea51e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-ads-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'wmr': patch
---

Always print stack traces on exceptions
1 change: 1 addition & 0 deletions packages/wmr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"cross-env": "^7.0.2",
"cssnano": "^4.1.10",
"devcert": "^1.1.2",
"errorstacks": "^2.3.0",
"es-module-lexer": "^0.4.1",
"eslint": "^7.4.0",
"eslint-config-developit": "^1.2.0",
Expand Down
9 changes: 7 additions & 2 deletions packages/wmr/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import sade from 'sade';
import build from './build.js';
import start from './start.js';
import serve from './serve.js';
import { parseStackTrace } from 'errorstacks';
import * as kl from 'kolorist';

const prog = sade('wmr');
Expand Down Expand Up @@ -51,8 +52,12 @@ prog.parse(process.argv);

function run(p) {
p.catch(err => {
const text = (process.env.DEBUG ? err.stack : err.message) || err + '';
process.stderr.write(`${kl.red(text)}\n`);
const text = err.message || err + '';
const stack =
parseStackTrace(err.stack)
.map(frame => frame.raw)
.join('\n') + '\n';
process.stderr.write(`\n${kl.red(text)}\n${kl.dim(stack)}\n`);
process.exit(p.code || 1);
});
}
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2828,6 +2828,11 @@ error-ex@^1.2.0, error-ex@^1.3.1:
dependencies:
is-arrayish "^0.2.1"

errorstacks@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/errorstacks/-/errorstacks-2.3.0.tgz#3073cab243ad3af0c4797ec329f3aa599f0a34df"
integrity sha512-VjCIUbEyLymy2N1M/uTniewz+j69YC2R7Sp1UiJn04RHwyIniBib6hUZwgmphAAZTOk7LRg/wryGFEJhblEd7Q==

es-abstract@^1.17.2:
version "1.17.7"
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.7.tgz#a4de61b2f66989fc7421676c1cb9787573ace54c"
Expand Down

0 comments on commit b3ea51e

Please sign in to comment.