mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-01-29 15:44:26 +00:00
Merge pull request #2299 from balena-io/catch-BalenaInvalidDeviceType
os download: Improve error message for misspelled device type names
This commit is contained in:
commit
3717d8cc0f
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user