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

Rethrowing original errors thrown in selector functions #1474

Merged
merged 2 commits into from
Nov 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/hooks/useSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ function useSelectorWithStoreAndSubscription(
selectedState = latestSelectedState.current
}
} catch (err) {
let errorMessage = `An error occurred while selecting the store state: ${err.message}.`

if (latestSubscriptionCallbackError.current) {
errorMessage += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\nOriginal stack trace:`
err.message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
}

throw new Error(errorMessage)
throw err
}

useIsomorphicLayoutEffect(() => {
Expand Down