next
Version:
The React Framework
37 lines (35 loc) • 1.77 kB
JavaScript
// This module can be shared between both pages router and app router
;
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "onRecoverableError", {
enumerable: true,
get: function() {
return onRecoverableError;
}
});
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
const _bailouttocsr = require("../../shared/lib/lazy-dynamic/bailout-to-csr");
const _reportglobalerror = require("./report-global-error");
const _stitchederror = require("../components/errors/stitched-error");
const _iserror = /*#__PURE__*/ _interop_require_default._(require("../../lib/is-error"));
const onRecoverableError = (error, errorInfo)=>{
// x-ref: https://github.com/facebook/react/pull/28736
const cause = (0, _iserror.default)(error) && 'cause' in error ? error.cause : error;
const stitchedError = (0, _stitchederror.getReactStitchedError)(cause);
// In development mode, pass along the component stack to the error
if (process.env.NODE_ENV === 'development' && errorInfo.componentStack) {
;
stitchedError._componentStack = errorInfo.componentStack;
}
// Skip certain custom errors which are not expected to be reported on client
if ((0, _bailouttocsr.isBailoutToCSRError)(cause)) return;
(0, _reportglobalerror.reportGlobalError)(stitchedError);
};
if ((typeof exports.default === 'function' || (typeof exports.default === 'object' && exports.default !== null)) && typeof exports.default.__esModule === 'undefined') {
Object.defineProperty(exports.default, '__esModule', { value: true });
Object.assign(exports.default, exports);
module.exports = exports.default;
}
//# sourceMappingURL=on-recoverable-error.js.map