"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CODES = exports.CLASSES = exports.MESSAGES = exports.UnableToOpenDisplayError = exports.UnableToAccessScreenRecordingAPIError = exports.UnableToAccessAutomationAPIError = exports.NativeBinaryHasFailedError = exports.UnableToRunBrowsersError = exports.BrowserPathNotSetError = void 0; const CODES = __importStar(require("./codes")); exports.CODES = CODES; const TEMPLATES = __importStar(require("../templates")); function getErrorCode(errorClass) { const code = Object .keys(CODES) .find(currentCode => exports.CLASSES[currentCode] === errorClass); // eslint-disable-line no-use-before-define return code || CODES.E000; } function getErrorInfo(errorClass) { const code = getErrorCode(errorClass); return { constructor: exports.CLASSES[code], message: exports.MESSAGES[code], code }; } class BasicError extends Error { constructor(data = {}) { const { code, constructor, message } = getErrorInfo(new.target); super(message(data)); this.name = constructor.name; this.data = data; this.code = code; } } class BrowserPathNotSetError extends BasicError { } exports.BrowserPathNotSetError = BrowserPathNotSetError; class UnableToRunBrowsersError extends BasicError { constructor({ path }) { super({ path }); } } exports.UnableToRunBrowsersError = UnableToRunBrowsersError; class NativeBinaryHasFailedError extends BasicError { constructor({ binary, exitCode, output }) { super({ binary, exitCode, output }); } } exports.NativeBinaryHasFailedError = NativeBinaryHasFailedError; class PermissionError extends NativeBinaryHasFailedError { } class UnableToAccessAutomationAPIError extends PermissionError { } exports.UnableToAccessAutomationAPIError = UnableToAccessAutomationAPIError; class UnableToAccessScreenRecordingAPIError extends PermissionError { } exports.UnableToAccessScreenRecordingAPIError = UnableToAccessScreenRecordingAPIError; class UnableToOpenDisplayError extends NativeBinaryHasFailedError { } exports.UnableToOpenDisplayError = UnableToOpenDisplayError; exports.MESSAGES = { [CODES.E000]: TEMPLATES.BASIC_ERROR_MESSAGE, [CODES.E001]: TEMPLATES.BROWSER_PATH_NOT_SET, [CODES.E002]: TEMPLATES.UNABLE_TO_RUN_BROWSERS, [CODES.E003]: TEMPLATES.NATIVE_BINARY_HAS_FAILED, [CODES.E004]: TEMPLATES.UNABLE_TO_ACCESS_AUTOMATION_API, [CODES.E005]: TEMPLATES.UNABLE_TO_ACCESS_SCREEN_RECORDING_API, [CODES.E006]: TEMPLATES.UNABLE_TO_OPEN_DISPLAY }; exports.CLASSES = { [CODES.E000]: BasicError, [CODES.E001]: BrowserPathNotSetError, [CODES.E002]: UnableToRunBrowsersError, [CODES.E003]: NativeBinaryHasFailedError, [CODES.E004]: UnableToAccessAutomationAPIError, [CODES.E005]: UnableToAccessScreenRecordingAPIError, [CODES.E006]: UnableToOpenDisplayError }; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZXJyb3JzL2luZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwrQ0FBaUM7QUF3RnhCLHNCQUFLO0FBdkZkLHdEQUEwQztBQUcxQyxTQUFTLFlBQVksQ0FBRSxVQUFVO0lBQzdCLE1BQU0sSUFBSSxHQUFHLE1BQU07U0FDZCxJQUFJLENBQUMsS0FBSyxDQUFDO1NBQ1gsSUFBSSxDQUFDLFdBQVcsQ0FBQyxFQUFFLENBQUMsZUFBTyxDQUFDLFdBQVc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