Skip to content

Commit 5402f24

Browse files
r3dm1ketimdorr
authored andcommitted
Rethrowing original errors thrown in selector functions (#1474)
* Added optional stacktrace to errors thrown from selector functions When throwing error from selector function, append original error stacktrace (if present) to new error. * Rethrowing original errors from selector functions
1 parent b198f26 commit 5402f24

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/hooks/useSelector.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ function useSelectorWithStoreAndSubscription(
3535
selectedState = latestSelectedState.current
3636
}
3737
} catch (err) {
38-
let errorMessage = `An error occurred while selecting the store state: ${err.message}.`
39-
4038
if (latestSubscriptionCallbackError.current) {
41-
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`
4240
}
4341

44-
throw new Error(errorMessage)
42+
throw err
4543
}
4644

4745
useIsomorphicLayoutEffect(() => {

0 commit comments

Comments
 (0)