Innovenergy_trunk/frontend/node_modules/testcafe-browser-tools/lib/errors/index.js

93 lines
9.6 KiB
JavaScript
Raw Permalink Normal View History

"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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZXJyb3JzL2luZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSwrQ0FBaUM7QUF3RnhCLHNCQUFLO0FBdkZkLHdEQUEwQztBQUcxQyxTQUFTLFl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