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

error overlay: show cause if available #6052

Merged
merged 3 commits into from
Jan 31, 2023
Merged

error overlay: show cause if available #6052

merged 3 commits into from
Jan 31, 2023

Conversation

mayank99
Copy link
Contributor

Changes

Added ability to display an error's cause if available. Closes #6027

Testing

Tested in a local project by changing code inside node modules.

Test fixture currently pending.

Docs

Not needed I think? I guess we could document how to use the cause property.

@changeset-bot
Copy link

changeset-bot bot commented Jan 31, 2023

🦋 Changeset detected

Latest commit: 4d867c5

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Jan 31, 2023
this.text('#cause-content', err.cause);
cause.style.display = 'block';
} else {
this.text('#cause-content', JSON.stringify(err.cause, null, 2));
Copy link
Contributor Author

@mayank99 mayank99 Jan 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally wanted to check if this is instanceof Error and display it, but for some reason err.cause is missing info and just returns an empty object when i do this:

try {
  console.log(something.that.doesnt.exist);
} catch (err) {
  throw new Error('oh no!', { cause: err });
}

@mayank99 mayank99 mentioned this pull request Jan 31, 2023
1 task
Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome stuff, thank you very much!

@Princesseuh Princesseuh merged commit 9793f19 into withastro:main Jan 31, 2023
@astrobot-houston astrobot-houston mentioned this pull request Jan 31, 2023
matthewp pushed a commit that referenced this pull request Feb 3, 2023
* show `cause` in error overlay

* add extra check for string

* add changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error overlay not showing cause
2 participants