@skbkontur/cassandra-distributed-task-queue-ui
Version:
.NET library implementing distributed task queue machinery using Apache Cassandra
55 lines • 2.18 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorHandlingContainer = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const ErrorHandlingContainerModal_1 = require("./ErrorHandlingContainerModal");
class ErrorHandlingContainer extends react_1.Component {
constructor() {
super(...arguments);
Object.defineProperty(this, "state", {
enumerable: true,
configurable: true,
writable: true,
value: {
isFatal: false,
error: null,
stack: null,
showModal: false,
}
});
Object.defineProperty(this, "oldOnunhandledrejection", {
enumerable: true,
configurable: true,
writable: true,
value: null
});
}
componentDidMount() {
this.oldOnunhandledrejection = window.onunhandledrejection;
window.onunhandledrejection = (e, ...restArgs) => {
if (this.oldOnunhandledrejection) {
this.oldOnunhandledrejection(e, ...restArgs);
}
if (typeof e.preventDefault === "function") {
e.preventDefault();
}
this.setState({
showModal: true,
isFatal: false,
error: e.reason,
stack: e.reason.stack,
});
};
}
componentWillUnmount() {
window.onunhandledrejection = this.oldOnunhandledrejection;
}
render() {
const { isFatal, showModal, stack, error } = this.state;
const { message, serverErrorType, serverStackTrace } = (error || {});
return ((0, jsx_runtime_1.jsx)("div", { children: showModal && ((0, jsx_runtime_1.jsx)(ErrorHandlingContainerModal_1.ErrorHandlingContainerModal, { canClose: !isFatal, onClose: () => this.setState({ showModal: false }), message: serverErrorType + ": " + message, stack: stack, serverStack: serverStackTrace })) }));
}
}
exports.ErrorHandlingContainer = ErrorHandlingContainer;
//# sourceMappingURL=ErrorHandlingContainer.js.map
;