NET-Web-API-w-Angular/my-app/node_modules/webpack-dev-server/client/overlay/runtime-error.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-02-09 00:38:41 +00:00
/**
*
* @param {Error} error
*/
function parseErrorToStacks(error) {
if (!error || !(error instanceof Error)) {
throw new Error("parseErrorToStacks expects Error object");
}
if (typeof error.stack === "string") {
return error.stack.split("\n").filter(function (stack) {
return stack !== "Error: ".concat(error.message);
});
}
}
/**
* @callback ErrorCallback
* @param {ErrorEvent} error
* @returns {void}
*/
/**
* @param {ErrorCallback} callback
*/
function listenToRuntimeError(callback) {
window.addEventListener("error", callback);
return function cleanup() {
window.removeEventListener("error", callback);
};
}
/**
* @callback UnhandledRejectionCallback
* @param {PromiseRejectionEvent} rejectionEvent
* @returns {void}
*/
/**
* @param {UnhandledRejectionCallback} callback
*/
function listenToUnhandledRejection(callback) {
window.addEventListener("unhandledrejection", callback);
return function cleanup() {
window.removeEventListener("unhandledrejection", callback);
};
}
export { listenToRuntimeError, listenToUnhandledRejection, parseErrorToStacks };