UNPKG

@skbkontur/cassandra-distributed-task-queue-ui

Version:

.NET library implementing distributed task queue machinery using Apache Cassandra

56 lines 2.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorHandlingContainer = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = tslib_1.__importDefault(require("react")); const ErrorHandlingContainerModal_1 = require("./ErrorHandlingContainerModal"); class ErrorHandlingContainer extends react_1.default.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 (jsx_runtime_1.jsx("div", { children: showModal && (jsx_runtime_1.jsx(ErrorHandlingContainerModal_1.ErrorHandlingContainerModal, { canClose: !isFatal, onClose: () => this.setState({ showModal: false }), message: serverErrorType + ": " + message, stack: stack, serverStack: serverStackTrace }, void 0)) }, void 0)); } } exports.ErrorHandlingContainer = ErrorHandlingContainer; //# sourceMappingURL=ErrorHandlingContainer.js.map