Skip to content

Commit

Permalink
fix: Throw ERR_UNSUPPORTED_API_LEVEL (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile committed Oct 11, 2021
1 parent ca5fc3f commit b879744
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/android/utils/avd.ts
Expand Up @@ -201,6 +201,7 @@ export async function getDefaultAVDSchematic(sdk: SDK): Promise<AVDSchematic> {
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 {
Expand All @@ -212,13 +213,21 @@ export async function getDefaultAVDSchematic(sdk: SDK): Promise<AVDSchematic> {
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,
);
Expand Down

0 comments on commit b879744

Please sign in to comment.