Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit e0b151a

Browse files
authored
fix(launcher): Handle uncaught exceptions that are strings. (#3506)
Also clean up instances where we were throwing strings instead of Errors.
1 parent 79184ff commit e0b151a

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

lib/browser.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,9 @@ export class ProtractorBrowser extends Webdriver {
448448
return runWaitForAngularScript()
449449
.then((browserErr: Function) => {
450450
if (browserErr) {
451-
throw 'Error while waiting for Protractor to ' +
452-
'sync with the page: ' + JSON.stringify(browserErr);
451+
throw new Error(
452+
'Error while waiting for Protractor to ' +
453+
'sync with the page: ' + JSON.stringify(browserErr));
453454
}
454455
})
455456
.then(
@@ -790,7 +791,8 @@ export class ProtractorBrowser extends Webdriver {
790791
return angularVersion;
791792
},
792793
(err: Error) => {
793-
throw 'Error while running testForAngular: ' + err.message;
794+
throw new Error(
795+
'Error while running testForAngular: ' + err.message);
794796
})
795797
.then(loadMocks, deferred.reject);
796798

@@ -812,8 +814,9 @@ export class ProtractorBrowser extends Webdriver {
812814
.then(
813815
null,
814816
(err: Error) => {
815-
throw 'Error while running module script ' + name + ': ' +
816-
err.message;
817+
throw new Error(
818+
'Error while running module script ' + name + ': ' +
819+
err.message);
817820
})
818821
.then(null, deferred.reject);
819822
}

lib/cli.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ optimist
7272
.string('capabilities.tunnel-identifier')
7373
.check(function(arg: any) {
7474
if (arg._.length > 1) {
75-
throw 'Error: more than one config file specified';
75+
throw new Error('Error: more than one config file specified');
7676
}
7777
});
7878

lib/exitCodes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class ErrorHandler {
8585
if (errMsgs && errMsgs.length > 0) {
8686
for (let errPos in errMsgs) {
8787
let errMsg = errMsgs[errPos];
88-
if (e.message.indexOf(errMsg) !== -1) {
88+
if (e.message && e.message.indexOf(errMsg) !== -1) {
8989
return true;
9090
}
9191
}

lib/launcher.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ let initFn = function(configFile: string, additionalConfig: Config) {
179179
// 4) Run tests.
180180
let scheduler = new TaskScheduler(config);
181181

182-
process.on('uncaughtException', (e: Error) => {
182+
process.on('uncaughtException', (exc: (Error|string)) => {
183+
let e = (exc instanceof Error) ? exc : new Error(exc);
184+
183185
let errorCode = ErrorHandler.parseError(e);
184186
if (errorCode) {
185187
let protractorError = e as ProtractorError;

0 commit comments

Comments
 (0)