DevTools: Correctly log errors reported from the store (#22950)
jstejada committed
Dec 13, 2021 at 12:02 UTC
575791925697c7e23966e6934b577e69aef736f3
1 file changed
+11
-6
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/ErrorBoundary.js
+11
-6
@@ -74,12 +74,7 @@ export default class ErrorBoundary extends Component<Props, State> {
74
}
75
76
componentDidCatch(error: any, {componentStack}: any) {
77
- logEvent({
78
- event_name: 'error',
79
- error_message: error.message ?? null,
80
- error_stack: error.stack ?? null,
81
- error_component_stack: componentStack ?? null,
82
- });
77
+ this._logError(error, componentStack);
78
this.setState({
79
componentStack,
80
});
@@ -146,6 +141,15 @@ export default class ErrorBoundary extends Component<Props, State> {
141
return children;
142
}
143
144
+ _logError = (error: any, componentStack: string | null) => {
145
+ logEvent({
146
+ event_name: 'error',
147
+ error_message: error.message ?? null,
148
+ error_stack: error.stack ?? null,
149
+ error_component_stack: componentStack ?? null,
150
+ });
151
+ };
152
+
153
_dismissError = () => {
154
const onBeforeDismissCallback = this.props.onBeforeDismissCallback;
155
if (typeof onBeforeDismissCallback === 'function') {
@@ -157,6 +161,7 @@ export default class ErrorBoundary extends Component<Props, State> {
161
162
_onStoreError = (error: Error) => {
163
if (!this.state.hasError) {
164
+ this._logError(error, null);
165
this.setState({
166
...ErrorBoundary.getDerivedStateFromError(error),
167
canDismiss: true,