From b879744c81bbc6b73c6a1a97064dcc51818b2fa5 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Mon, 11 Oct 2021 18:23:02 +0200 Subject: [PATCH] fix: Throw ERR_UNSUPPORTED_API_LEVEL (#204) --- src/android/utils/avd.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/android/utils/avd.ts b/src/android/utils/avd.ts index c65ecda..e4a0043 100644 --- a/src/android/utils/avd.ts +++ b/src/android/utils/avd.ts @@ -201,6 +201,7 @@ export async function getDefaultAVDSchematic(sdk: SDK): Promise { const debug = Debug(`${modulePrefix}:${getDefaultAVDSchematic.name}`); const packages = await findAllSDKPackages(sdk); const apis = await getAPILevels(packages); + const errors: AVDException[] = []; for (const api of apis) { try { @@ -212,13 +213,21 @@ export async function getDefaultAVDSchematic(sdk: SDK): Promise { if (!(e instanceof AVDException)) { throw e; } - + errors.push(e); debug('Issue with API %s: %s', api.apiLevel, e.message); } } + if (errors.length > 0) { + const unsupportedError = errors.find( + e => e.code === ERR_UNSUPPORTED_API_LEVEL, + ); + if (unsupportedError) { + throw unsupportedError; + } + } throw new AVDException( - 'No suitable API installation found.', + 'No suitable API installation found. Use --sdk-info to reveal missing packages and other issues.', ERR_UNSUITABLE_API_INSTALLATION, 1, );