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

useErrorHandler: use unknown instead of Error #89

Merged
merged 2 commits into from May 5, 2021

Conversation

tommarien
Copy link
Contributor

In the useErrorHandler hook, i've changed the type of the error from Error to unknown.

What:

Not all thrown exceptions are of type Error, see #83 for a discussion concerning this change

Why:
NA

How:

I've made the changes as agreed upon and also corrected the documentation

Checklist:

  • Documentation
  • Tests
  • Ready to be merged

I've noticed that current master has a linting issue on the fallback in the render method, i'll take a look at it

Copy link
Collaborator

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks!

function useErrorHandler(givenError?: unknown): (error: unknown) => void {
const [error, setError] = React.useState<unknown>(null)
if (givenError != null) throw givenError
if (error != null) throw error
Copy link
Collaborator

Choose a reason for hiding this comment

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

Those might give you a lint issue. If it does, you can just disable the rule for the project/file.

@tommarien
Copy link
Contributor Author

@kentcdodds for the validating step here is the issue i mentioned already present on master, see my other pull to fix that issue

@kentcdodds kentcdodds merged commit ec81d61 into bvaughn:master May 5, 2021
@github-actions
Copy link

github-actions bot commented May 5, 2021

🎉 This PR is included in version 3.1.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@tommarien tommarien deleted the fix-error-type branch May 10, 2021 06:19
@vladkens vladkens mentioned this pull request Sep 17, 2021
3 tasks
@parkgang parkgang mentioned this pull request Apr 12, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants