diff --git a/lib/commands/powershell.js b/lib/commands/powershell.js index e6190ca..5e361fd 100644 --- a/lib/commands/powershell.js +++ b/lib/commands/powershell.js @@ -41,10 +41,10 @@ commands.execPowerShell = async function execPowerShell (opts) { command, } = opts ?? {}; if (!script && !command) { - this.log.errorAndThrow('Power Shell script/command must not be empty'); + throw this.log.errorWithException('Power Shell script/command must not be empty'); } if (/\n/.test(command ?? '')) { - this.log.errorAndThrow('Power Shell commands cannot contain line breaks'); + throw this.log.errorWithException('Power Shell commands cannot contain line breaks'); } const shouldRunScript = !command && !!script; diff --git a/lib/commands/record-screen.js b/lib/commands/record-screen.js index 8478469..b505f14 100644 --- a/lib/commands/record-screen.js +++ b/lib/commands/record-screen.js @@ -52,6 +52,11 @@ async function requireFfmpegPath () { } class ScreenRecorder { + /** + * @param {string} videoPath + * @param {import('@appium/types').AppiumLogger} log + * @param {import('@appium/types').StringRecord} opts + */ constructor (videoPath, log, opts = {}) { this.log = log; this._videoPath = videoPath; @@ -152,8 +157,10 @@ class ScreenRecorder { }); } catch (e) { await this._enforceTermination(); - this.log.errorAndThrow(`The expected screen record file '${this._videoPath}' does not exist. ` + - `Check the server log for more details`); + throw this.log.errorWithException( + `The expected screen record file '${this._videoPath}' does not exist. ` + + `Check the server log for more details` + ); } this.log.info(`The video recording has started. Will timeout in ${util.pluralize('second', this._timeLimit, true)}`); } diff --git a/lib/winappdriver.js b/lib/winappdriver.js index 0fa755f..a1b6ddb 100644 --- a/lib/winappdriver.js +++ b/lib/winappdriver.js @@ -26,6 +26,9 @@ class WADProxy extends JWProxy { /** @type {boolean|undefined} */ didProcessExit; + /** + * @override + */ async proxyCommand (url, method, body = null) { if (this.didProcessExit) { throw new errors.InvalidContextError( @@ -37,7 +40,12 @@ class WADProxy extends JWProxy { } class WADProcess { - constructor (log, opts = {}) { + /** + * + * @param {import('@appium/types').AppiumLogger} log + * @param {{base: string, port: number, executablePath: string, isForceQuitEnabled: boolean}} opts + */ + constructor (log, opts) { this.log = log; this.base = opts.base; this.port = opts.port; @@ -61,7 +69,7 @@ class WADProcess { try { this.port = await findAPortNotInUse(startPort, endPort); } catch (e) { - this.log.errorAndThrow( + throw this.log.errorWithException( `Could not find any free port in range ${startPort}..${endPort}. ` + `Please check your system firewall settings or set 'systemPort' capability ` + `to the desired port number`); @@ -116,7 +124,12 @@ process.once('exit', () => { }); class WinAppDriver { - constructor (log, opts = {}) { + /** + * + * @param {import('@appium/types').AppiumLogger} log + * @param {{port: number}} opts + */ + constructor (log, opts) { this.log = log; this.proxyPort = opts.port;