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

Commit

Permalink
fix(error message): do not crash of thrown error has made stack rea…
Browse files Browse the repository at this point in the history
…donly (#3372)
  • Loading branch information
sjelin authored and cnishina committed Jul 19, 2016
1 parent 7c285dc commit ee038f9
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lib/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,16 +429,23 @@ export class ElementArrayFinder extends WebdriverWebElement {
*/
applyAction_(actionFn: Function): ElementArrayFinder {
let callerError = new Error();
let actionResults = this.getWebElements()
.then((arr: any) => {
return webdriver.promise.all(arr.map(actionFn));
})
.then(null, (e: Error) => {
let noSuchErr = (e as any);
noSuchErr.stack =
noSuchErr.stack + (callerError as any).stack;
throw noSuchErr;
});
let actionResults =
this.getWebElements()
.then((arr: any) => {
return webdriver.promise.all(arr.map(actionFn));
})
.then(null, (e: Error) => {
let noSuchErr: any;
let stack: string;
if (e instanceof Error) {
noSuchErr = (e as any)
noSuchErr.stack = noSuchErr.stack + (callerError as any).stack;
} else {
noSuchErr = (new Error(e.toString()) as any);
noSuchErr.stack = (callerError as any).stack;
}
throw noSuchErr;
});
return new ElementArrayFinder(
this.browser_, this.getWebElements, this.locator_, actionResults);
}
Expand Down

0 comments on commit ee038f9

Please sign in to comment.