@embrace-io/web-sdk
Version:
32 lines (31 loc) • 972 B
JavaScript
import { KEY_EMB_INSTRUMENTATION } from "../../../../constants/attributes.js";
import { log } from "../../../../api-logs/logAPI.js";
import * as React$1 from "react";
//#region src/instrumentations/exceptions/react/EmbraceErrorBoundary/EmbraceErrorBoundary.ts
var EmbraceErrorBoundary = class extends React$1.Component {
_logManager;
constructor(props) {
super(props);
this._logManager = log.getLogManager();
this.state = { hasError: false };
}
static getDerivedStateFromError() {
return { hasError: true };
}
componentDidCatch(error, errorInfo) {
this._logManager.logException(error, {
handled: false,
attributes: {
"react.component_stack": errorInfo.componentStack ?? void 0,
[KEY_EMB_INSTRUMENTATION]: "react_error_boundary"
}
});
}
render() {
if (this.state.hasError) return this.props.fallback();
return this.props.children;
}
};
//#endregion
export { EmbraceErrorBoundary };
//# sourceMappingURL=EmbraceErrorBoundary.js.map