From 18371f296fb8a3cb0ab070f2c5316f98e9351263 Mon Sep 17 00:00:00 2001 From: Daniel Imhoff Date: Thu, 10 Sep 2020 11:47:33 -0700 Subject: [PATCH] fix(ios): do not falsely link to Android Wiki for iOS errors --- src/android/run.ts | 10 +++++----- src/errors.ts | 12 ++++++++++-- src/ios/run.ts | 6 +++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/android/run.ts b/src/android/run.ts index 4208753..612c029 100644 --- a/src/android/run.ts +++ b/src/android/run.ts @@ -1,6 +1,6 @@ import * as Debug from 'debug'; -import { AVDException, CLIException, ERR_BAD_INPUT, ERR_NO_DEVICE, ERR_NO_TARGET, ERR_TARGET_NOT_FOUND, ERR_UNSUITABLE_API_INSTALLATION, RunException } from '../errors'; +import { AVDException, AndroidRunException, CLIException, ERR_BAD_INPUT, ERR_NO_DEVICE, ERR_NO_TARGET, ERR_TARGET_NOT_FOUND, ERR_UNSUITABLE_API_INSTALLATION } from '../errors'; import { getOptionValue, getOptionValues } from '../utils/cli'; import { log } from '../utils/log'; import { onBeforeExit } from '../utils/process'; @@ -90,7 +90,7 @@ export async function selectDevice(sdk: SDK, args: readonly string[]): Promise {} -export type RunExceptionCode = ( +export type AndroidRunExceptionCode = ( typeof ERR_NO_AVDS_FOUND | typeof ERR_TARGET_NOT_FOUND | typeof ERR_NO_DEVICE | typeof ERR_NO_TARGET ); -export class RunException extends AndroidException {} +export class AndroidRunException extends AndroidException {} export type SDKExceptionCode = ( typeof ERR_AVD_HOME_NOT_FOUND | @@ -113,6 +113,14 @@ export type SDKExceptionCode = ( export class SDKException extends AndroidException {} +export type IOSRunExceptionCode = ( + typeof ERR_TARGET_NOT_FOUND | + typeof ERR_NO_DEVICE | + typeof ERR_NO_TARGET +); + +export class IOSRunException extends Exception {} + export function serializeError(e = new Error()): string { const stack = String(e.stack ? e.stack : e); diff --git a/src/ios/run.ts b/src/ios/run.ts index 90f5057..8e65c2f 100644 --- a/src/ios/run.ts +++ b/src/ios/run.ts @@ -3,7 +3,7 @@ import * as Debug from 'debug'; import { existsSync, mkdtempSync } from 'fs'; import * as path from 'path'; -import { CLIException, ERR_BAD_INPUT, ERR_TARGET_NOT_FOUND, RunException } from '../errors'; +import { CLIException, ERR_BAD_INPUT, ERR_TARGET_NOT_FOUND, IOSRunException } from '../errors'; import { getOptionValue } from '../utils/cli'; import { getBundleId, unzipIPA } from './utils/app'; @@ -23,7 +23,7 @@ export async function run(args: readonly string[]): Promise { const isIPA = appPath.endsWith('.ipa'); if (!existsSync(appPath)) { - throw new RunException(`Path '${appPath}' not found`); + throw new IOSRunException(`Path '${appPath}' not found`); } try { @@ -48,7 +48,7 @@ export async function run(args: readonly string[]): Promise { } else if (simulators.find(s => s.udid === udid)) { await runOnSimulator(udid, appPath, bundleId, waitForApp); } else { - throw new RunException(`No device or simulator with UDID "${udid}" found`, ERR_TARGET_NOT_FOUND); + throw new IOSRunException(`No device or simulator with UDID "${udid}" found`, ERR_TARGET_NOT_FOUND); } } else if (devices.length && !preferSimulator) { // no udid, use first connected device