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

fix(launcher): Handle uncaught exceptions that are strings. #3506

Merged
merged 3 commits into from
Sep 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,9 @@ export class ProtractorBrowser extends Webdriver {
return runWaitForAngularScript()
.then((browserErr: Function) => {
if (browserErr) {
throw 'Error while waiting for Protractor to ' +
'sync with the page: ' + JSON.stringify(browserErr);
throw new Error(
'Error while waiting for Protractor to ' +
'sync with the page: ' + JSON.stringify(browserErr));
}
})
.then(
Expand Down Expand Up @@ -790,7 +791,8 @@ export class ProtractorBrowser extends Webdriver {
return angularVersion;
},
(err: Error) => {
throw 'Error while running testForAngular: ' + err.message;
throw new Error(
'Error while running testForAngular: ' + err.message);
})
.then(loadMocks, deferred.reject);

Expand All @@ -812,8 +814,9 @@ export class ProtractorBrowser extends Webdriver {
.then(
null,
(err: Error) => {
throw 'Error while running module script ' + name + ': ' +
err.message;
throw new Error(
'Error while running module script ' + name + ': ' +
err.message);
})
.then(null, deferred.reject);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ optimist
.string('capabilities.tunnel-identifier')
.check(function(arg: any) {
if (arg._.length > 1) {
throw 'Error: more than one config file specified';
throw new Error('Error: more than one config file specified');
}
});

Expand Down
2 changes: 1 addition & 1 deletion lib/exitCodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class ErrorHandler {
if (errMsgs && errMsgs.length > 0) {
for (let errPos in errMsgs) {
let errMsg = errMsgs[errPos];
if (e.message.indexOf(errMsg) !== -1) {
if (e.message && e.message.indexOf(errMsg) !== -1) {
return true;
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ let initFn = function(configFile: string, additionalConfig: Config) {
// 4) Run tests.
let scheduler = new TaskScheduler(config);

process.on('uncaughtException', (e: Error) => {
process.on('uncaughtException', (exc: (Error|string)) => {
let e = (exc instanceof Error) ? exc : new Error(exc);

let errorCode = ErrorHandler.parseError(e);
if (errorCode) {
let protractorError = e as ProtractorError;
Expand Down