From ca9767835852da53758f8e9713db85357f22ba8b Mon Sep 17 00:00:00 2001 From: Thodoris Greasidis Date: Tue, 8 Nov 2022 10:48:05 +0200 Subject: [PATCH] Fix surfacing incompatible device type errors as not recognized Change-type: patch Signed-off-by: Thodoris Greasidis --- lib/errors.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/errors.ts b/lib/errors.ts index 2552b7e0..157bc318 100644 --- a/lib/errors.ts +++ b/lib/errors.ts @@ -177,7 +177,16 @@ const messages: { Looks like the session token has expired. 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'; return stripIndent` Device type ${slug} not recognized. Perhaps misspelled?