pillarjs / pillarjs/finalhandler

Print causes when outputting error stacks

Open
#41 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
241
Forks
54
Avg merge
7h 21m
Merged PRs (30d)
1

Description

In getErrorMessage, which is used to create a pretty error messages that is both logged and returned to clients in non-production environments, the error message is found by simply taking err.stack.

Errors now support the cause option (not really well-documented in Node.js documentation, but it's on MDN), which allows listing originating causes for an error (for example, if an error is thrown as the result of a different error).

err.stack does not print this, but for example browser consoles show the causes nicely:

image

Would you be interested in a PR adding the cause chain to the output of getErrorMessage? I think this would be a nice addition, and I would personally find it useful 😄

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in index.js at getErrorMessage, where the message currently uses err.stack. Review how the cause option is represented and define output that includes the cause chain, then verify that non-production error responses and logs include it without losing the existing stack output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.