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.

@kongmoumou
Copy link
Author

@ pi0 Could you let me know any progress of this feat? Looking forward to ur thought~ 😂

@pi0
Copy link
Member

pi0 commented Dec 2, 2024

@kongmoumou it is on my list sorry got delayed (i might need to push small refactors before)

Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 9.09091% with 10 lines in your changes missing coverage. Please review.

Project coverage is 22.11%. Comparing base (24c98ce) to head (1a39b36).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
src/reporters/basic.ts 9.09% 10 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #308       +/-   ##
===========================================
- Coverage   61.08%   22.11%   -38.98%     
===========================================
  Files          13       42       +29     
  Lines        1380     2180      +800     
  Branches       58       87       +29     
===========================================
- Hits          843      482      -361     
- Misses        537     1671     +1134     
- Partials        0       27       +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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