Skip to content

Commit f310d64

Browse files
committed
Rethrowing original errors from selector functions
1 parent 9706cc6 commit f310d64

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/hooks/useSelector.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@ function useSelectorWithStoreAndSubscription(
3535
selectedState = latestSelectedState.current
3636
}
3737
} catch (err) {
38-
let errorMessage = `An error occurred while selecting the store state: `
39-
errorMessage += err.stack ? `\n${err.stack}\n` : err.message
40-
4138
if (latestSubscriptionCallbackError.current) {
42-
errorMessage += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\nOriginal stack trace:`
39+
err.message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
4340
}
4441

45-
throw new Error(errorMessage)
42+
throw err
4643
}
4744

4845
useIsomorphicLayoutEffect(() => {

0 commit comments

Comments
 (0)