Skip to content

Commit 9706cc6

Browse files
committed
Added optional stacktrace to errors thrown from selector functions
When throwing error from selector function, append original error stacktrace (if present) to new error.
1 parent b198f26 commit 9706cc6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/hooks/useSelector.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ function useSelectorWithStoreAndSubscription(
3535
selectedState = latestSelectedState.current
3636
}
3737
} catch (err) {
38-
let errorMessage = `An error occurred while selecting the store state: ${err.message}.`
38+
let errorMessage = `An error occurred while selecting the store state: `
39+
errorMessage += err.stack ? `\n${err.stack}\n` : err.message
3940

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

0 commit comments

Comments
 (0)