DevTools: Correctly log errors reported from the store (#22950)

This commit is contained in:
jstejada
2021-12-13 12:02:14 -05:00
committed by GitHub
parent a049aa0155
commit 5757919256

View File

@@ -74,12 +74,7 @@ export default class ErrorBoundary extends Component<Props, State> {
}
componentDidCatch(error: any, {componentStack}: any) {
logEvent({
event_name: 'error',
error_message: error.message ?? null,
error_stack: error.stack ?? null,
error_component_stack: componentStack ?? null,
});
this._logError(error, componentStack);
this.setState({
componentStack,
});
@@ -146,6 +141,15 @@ export default class ErrorBoundary extends Component<Props, State> {
return children;
}
_logError = (error: any, componentStack: string | null) => {
logEvent({
event_name: 'error',
error_message: error.message ?? null,
error_stack: error.stack ?? null,
error_component_stack: componentStack ?? null,
});
};
_dismissError = () => {
const onBeforeDismissCallback = this.props.onBeforeDismissCallback;
if (typeof onBeforeDismissCallback === 'function') {
@@ -157,6 +161,7 @@ export default class ErrorBoundary extends Component<Props, State> {
_onStoreError = (error: Error) => {
if (!this.state.hasError) {
this._logError(error, null);
this.setState({
...ErrorBoundary.getDerivedStateFromError(error),
canDismiss: true,