Skip to content

Support for printing error causes - #234

Open
dwoznicki wants to merge 1 commit into
lukeed:masterfrom
dwoznicki:error-cause
Open

Support for printing error causes#234
dwoznicki wants to merge 1 commit into
lukeed:masterfrom
dwoznicki:error-cause

Conversation

@dwoznicki

Copy link
Copy Markdown

This PR adds support for printing error cause. Causes appear as part of the stack trace, and are checked recursively. For example, the following snippet

const {test} = require("uvu");

test("error cause", () => {
    throw new Error("top level", {cause: new Error("mid level", {cause: new Error("bottom level")})});
});
test.run();

produces the following output

✘   (0 / 1)

   FAIL  "error cause"
    top level

    at Object.handler (/home/danwoz/testo/test/t.js:4:11)
    at Number.runner (/home/danwoz/testo/node_modules/uvu/dist/index.js:88:16)
    at Timeout.exec [as _onTimeout] (/home/danwoz/testo/node_modules/uvu/dist/index.js:151:39)

    Caused by: mid level
    at Object.handler (/home/danwoz/testo/test/t.js:4:42)
    at Number.runner (/home/danwoz/testo/node_modules/uvu/dist/index.js:88:16)
    at Timeout.exec [as _onTimeout] (/home/danwoz/testo/node_modules/uvu/dist/index.js:151:39)

    Caused by: bottom level
    at Object.handler (/home/danwoz/testo/test/t.js:4:73)
    at Number.runner (/home/danwoz/testo/node_modules/uvu/dist/index.js:88:16)
    at Timeout.exec [as _onTimeout] (/home/danwoz/testo/node_modules/uvu/dist/index.js:151:39)



  Total:     1
  Passed:    0
  Skipped:   0
  Duration:  2.76ms

Fixes #233

printing is recursive, so arbitrarily deep cause stacks should be
printed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error cause not printed

1 participant