Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Replace occurrences of the deprecated errorAndThrow API #286

Merged
merged 1 commit into from
Dec 12, 2024
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
4 changes: 2 additions & 2 deletions lib/commands/powershell.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 9 additions & 2 deletions lib/commands/record-screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)}`);
}
Expand Down
19 changes: 16 additions & 3 deletions lib/winappdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
Expand All @@ -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`);
Expand Down Expand Up @@ -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;

Expand Down
Loading