Skip to content

Commit 0d5ded6

Browse files
committed
Try marking errors in catch blocks
1 parent 5b68e0e commit 0d5ded6

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/components/connectAdvanced.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ function subscribeUpdates(
113113
latestStoreState,
114114
lastWrapperProps.current
115115
)
116-
} catch (e) {
116+
} catch (e: unknown) {
117117
error = e
118-
lastThrownError = e
118+
lastThrownError = e as Error | null
119119
}
120120

121121
if (!error) {

src/hooks/useSelector.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ function useSelectorWithStoreAndSubscription<TStoreState, TSelectedState>(
5050
} else {
5151
selectedState = latestSelectedState.current
5252
}
53-
} catch (err) {
53+
} catch (err: unknown) {
5454
if (latestSubscriptionCallbackError.current) {
55-
err.message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
55+
;(
56+
err as Error
57+
).message += `\nThe error may be correlated with this previous error:\n${latestSubscriptionCallbackError.current.stack}\n\n`
5658
}
5759

5860
throw err
@@ -77,12 +79,12 @@ function useSelectorWithStoreAndSubscription<TStoreState, TSelectedState>(
7779

7880
latestSelectedState.current = newSelectedState
7981
latestStoreState.current = newStoreState
80-
} catch (err) {
82+
} catch (err: unknown) {
8183
// we ignore all errors here, since when the component
8284
// is re-rendered, the selectors are called again, and
8385
// will throw again, if neither props nor store state
8486
// changed
85-
latestSubscriptionCallbackError.current = err
87+
latestSubscriptionCallbackError.current = err as Error
8688
}
8789

8890
forceRender()

0 commit comments

Comments
 (0)