UNPKG

cabbie-sync

Version:
78 lines (66 loc) 2.27 kB
/** * * This file is generated automatically, run npm run build to re-generate. **/'use strict'; // This file lists the status values that can be returned // along with their name/meaning. // // source: https://code.google.com/p/selenium/wiki/JsonWireProtocol#Response_Status_Codes ////////////////// // Enumerations // ////////////////// /* * List of errors * * @type {Object} */ Object.defineProperty(exports, "__esModule", { value: true }); exports.names = undefined; exports.fromBody = fromBody; var _flowRuntime = require('flow-runtime'); var _flowRuntime2 = _interopRequireDefault(_flowRuntime); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var names = exports.names = { '6': 'NoSuchDriver', '7': 'NoSuchElement', '8': 'NoSuchFrame', '9': 'UnknownCommand', '10': 'StaleElementReference', '11': 'ElementNotVisible', '12': 'InvalidElementState', '13': 'UnknownError', '15': 'ElementIsNotSelectable', '17': 'JavaScriptError', '19': 'XPathLookupError', '21': 'Timeout', '23': 'NoSuchWindow', '24': 'InvalidCookieDomain', '25': 'UnableToSetCookie', '26': 'UnexpectedAlertOpen', '27': 'NoAlertOpenError', '28': 'ScriptTimeout', '30': 'IMENotAvailable', '31': 'IMEEngineActivationFailed', '32': 'InvalidSelector', '33': 'SessionNotCreatedException', '34': 'MoveTargetOutOfBounds' }; //////////////////// // Public Methods // //////////////////// /* * Extracts the error message from a response body */ function fromBody(body /*: Object*/) /*: Error*/ { var _bodyType = _flowRuntime2.default.object(); var _returnType = _flowRuntime2.default.return(_flowRuntime2.default.ref('Error')); _flowRuntime2.default.param('body', _bodyType).assert(body); var msg = body.value && body.value.message ? body.value.message : body.value; var err = new Error(msg); err.name = names[body.status] || 'UnknownSeleniumError'; _flowRuntime2.default.any().assert(err).code = names[body.status] || 'UnknownSeleniumError'; return _returnType.assert(err); } _flowRuntime2.default.annotate(fromBody, _flowRuntime2.default.function(_flowRuntime2.default.param('body', _flowRuntime2.default.object()), _flowRuntime2.default.return(_flowRuntime2.default.ref('Error'))));