Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support report error cause #308

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kongmoumou
Copy link

@kongmoumou kongmoumou commented Jul 9, 2024

The cause property of Error had been support in most runtime and been widely adapted by many repo.

The Chrome devtool already support showing caused error like screenshot below ⬇️

image

This PR support report error cause to console while used in node. Related issue #202

image

Test code provided:

import { consola } from "./src/index";

consola.error(
  new Error("This is an error", {
    cause: new Error("This is the cause", {
      cause: new Error("This is the cause of the cause"),
    }),
  }),
);

@pi0 pi0 changed the title feat: support report error cause #202 feat: support report error cause Jul 9, 2024
@kongmoumou kongmoumou mentioned this pull request Jul 10, 2024
1 task
@kongmoumou
Copy link
Author

Hi, @pi0 ~ What's your thought of this feature? Looking forward to your reply. 🫡

@DrJume
Copy link

DrJume commented Oct 13, 2024

This would be so good to have! The cause adds important context in many errors (e.g. fetch errors with undici).
I didn't know that consola hides it and lost some time because of it, because I didn't get all information from the error.

Also the name/type of the error (e.g. "TypeError: ") gets lost with consola.

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.

3 participants