UNPKG

e2ed

Version:

E2E testing framework over Playwright

31 lines (30 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getGlobalErrorHandler = void 0; const internal_1 = require("../constants/internal"); const error_1 = require("./error"); const fs_1 = require("./fs"); const generalLog_1 = require("./generalLog"); /** * Get handler for `uncaughtException` and `unhandledRejection` errors. * @internal */ const getGlobalErrorHandler = (type) => (cause) => { try { const error = new error_1.E2edError(`Caught ${type}`, { cause }); const errorString = error.toString(); if (errorString.includes(internal_1.TARGET_CLOSED_ERROR_MESSAGE) || errorString.includes(internal_1.TEST_ENDED_ERROR_MESSAGE)) { return; } if (type === 'TestUnhandledRejection') { void (0, fs_1.writeGlobalWarning)(errorString).catch(() => { }); } else { void (0, fs_1.writeGlobalError)(errorString).catch(() => { }); } void (0, generalLog_1.writeLogsToFile)().catch(() => { }); } catch { } }; exports.getGlobalErrorHandler = getGlobalErrorHandler;