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

Commit ee038f9

Browse files
sjelincnishina
authored andcommitted
fix(error message): do not crash of thrown error has made stack readonly (#3372)
1 parent 7c285dc commit ee038f9

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

lib/element.ts

+17-10
Original file line numberDiff line numberDiff line change
@@ -429,16 +429,23 @@ export class ElementArrayFinder extends WebdriverWebElement {
429429
*/
430430
applyAction_(actionFn: Function): ElementArrayFinder {
431431
let callerError = new Error();
432-
let actionResults = this.getWebElements()
433-
.then((arr: any) => {
434-
return webdriver.promise.all(arr.map(actionFn));
435-
})
436-
.then(null, (e: Error) => {
437-
let noSuchErr = (e as any);
438-
noSuchErr.stack =
439-
noSuchErr.stack + (callerError as any).stack;
440-
throw noSuchErr;
441-
});
432+
let actionResults =
433+
this.getWebElements()
434+
.then((arr: any) => {
435+
return webdriver.promise.all(arr.map(actionFn));
436+
})
437+
.then(null, (e: Error) => {
438+
let noSuchErr: any;
439+
let stack: string;
440+
if (e instanceof Error) {
441+
noSuchErr = (e as any)
442+
noSuchErr.stack = noSuchErr.stack + (callerError as any).stack;
443+
} else {
444+
noSuchErr = (new Error(e.toString()) as any);
445+
noSuchErr.stack = (callerError as any).stack;
446+
}
447+
throw noSuchErr;
448+
});
442449
return new ElementArrayFinder(
443450
this.browser_, this.getWebElements, this.locator_, actionResults);
444451
}

0 commit comments

Comments
 (0)