Fix surfacing incompatible device type errors as not recognized

Change-type: patch
Signed-off-by: Thodoris Greasidis <thodoris@balena.io>
This commit is contained in:
Thodoris Greasidis 2022-11-08 10:48:05 +02:00 committed by Anton Belodedenko
parent 3bb0036ba8
commit ca97678358

View File

@ -177,7 +177,16 @@ const messages: {
Looks like the session token has expired. Looks like the session token has expired.
Try logging in again with the "balena login" command.`, Try logging in again with the "balena login" command.`,
BalenaInvalidDeviceType: (error: Error & { deviceTypeSlug?: string }) => { BalenaInvalidDeviceType: (
error: Error & { deviceTypeSlug?: string; type?: string },
) => {
// TODO: The SDK should be throwing a different Error for this case.
if (
typeof error.type === 'string' &&
error.type.startsWith('Incompatible ')
) {
return error.type;
}
const slug = error.deviceTypeSlug ? `"${error.deviceTypeSlug}"` : 'slug'; const slug = error.deviceTypeSlug ? `"${error.deviceTypeSlug}"` : 'slug';
return stripIndent` return stripIndent`
Device type ${slug} not recognized. Perhaps misspelled? Device type ${slug} not recognized. Perhaps misspelled?