exitCodes.js
3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
"use strict";
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var CONFIG_ERROR_CODE = 105;
var BROWSER_CONNECT_ERROR_CODE = 135;
var KITCHEN_SINK_CODE = 199;
var IError = (function (_super) {
__extends(IError, _super);
function IError() {
return _super.apply(this, arguments) || this;
}
return IError;
}(Error));
exports.IError = IError;
var ProtractorError = (function (_super) {
__extends(ProtractorError, _super);
function ProtractorError(logger, message, code, error) {
var _this = _super.call(this, message) || this;
_this.message = message;
_this.code = code;
// replacing the stack trace with the thrown error stack trace.
if (error) {
var protractorError = error;
_this.stack = protractorError.stack;
}
ProtractorError.log(logger, _this.code, _this.message, _this.stack);
if (!ProtractorError.SUPRESS_EXIT_CODE) {
process.exit(_this.code);
}
return _this;
}
ProtractorError.log = function (logger, code, message, stack) {
var messages = message.split('\n');
if (messages.length > 1) {
message = messages[0];
}
logger.error('Error code: ' + code);
logger.error('Error message: ' + message);
logger.error(stack);
};
return ProtractorError;
}(IError));
ProtractorError.CODE = KITCHEN_SINK_CODE;
ProtractorError.SUPRESS_EXIT_CODE = false;
exports.ProtractorError = ProtractorError;
/**
* Configuration file error
*/
var ConfigError = (function (_super) {
__extends(ConfigError, _super);
function ConfigError(logger, message, error) {
return _super.call(this, logger, message, ConfigError.CODE, error) || this;
}
return ConfigError;
}(ProtractorError));
ConfigError.CODE = CONFIG_ERROR_CODE;
exports.ConfigError = ConfigError;
/**
* Browser errors including getting a driver session, direct connect, etc.
*/
var BrowserError = (function (_super) {
__extends(BrowserError, _super);
function BrowserError(logger, message) {
return _super.call(this, logger, message, BrowserError.CODE) || this;
}
return BrowserError;
}(ProtractorError));
BrowserError.CODE = BROWSER_CONNECT_ERROR_CODE;
BrowserError.ERR_MSGS = [
'ECONNREFUSED connect ECONNREFUSED', 'Sauce Labs Authentication Error',
'Invalid username or password'
];
exports.BrowserError = BrowserError;
var ErrorHandler = (function () {
function ErrorHandler() {
}
ErrorHandler.isError = function (errMsgs, e) {
if (errMsgs && errMsgs.length > 0) {
for (var errPos in errMsgs) {
var errMsg = errMsgs[errPos];
if (e.message && e.message.indexOf(errMsg) !== -1) {
return true;
}
}
}
return false;
};
ErrorHandler.parseError = function (e) {
if (ErrorHandler.isError(ConfigError.ERR_MSGS, e)) {
return ConfigError.CODE;
}
if (ErrorHandler.isError(BrowserError.ERR_MSGS, e)) {
return BrowserError.CODE;
}
return null;
};
return ErrorHandler;
}());
exports.ErrorHandler = ErrorHandler;