diff --git a/lib/commands/os/download.ts b/lib/commands/os/download.ts index ac85ecaa..52c2f628 100644 --- a/lib/commands/os/download.ts +++ b/lib/commands/os/download.ts @@ -95,6 +95,11 @@ export default class OsDownloadCmd extends Command { const { downloadOSImage } = await import('../../utils/cloud'); - await downloadOSImage(params.type, options.output, options.version); + try { + await downloadOSImage(params.type, options.output, options.version); + } catch (e) { + e.deviceTypeSlug = params.type; + throw e; + } } } diff --git a/lib/errors.ts b/lib/errors.ts index f399ae7e..bd876c7e 100644 --- a/lib/errors.ts +++ b/lib/errors.ts @@ -174,6 +174,13 @@ const messages: { BalenaExpiredToken: () => stripIndent` Looks like the session token has expired. Try logging in again with the "balena login" command.`, + + BalenaInvalidDeviceType: (error: Error & { deviceTypeSlug?: string }) => { + const slug = error.deviceTypeSlug ? `"${error.deviceTypeSlug}"` : 'slug'; + return stripIndent` + Device type ${slug} not recognized. Perhaps misspelled? + Check available device types with "balena devices supported"`; + }, }; // TODO remove these regexes when we have a way of uniquely indentifying errors.