From 9f8569e33fd01bcac4249172338d64537a4eeaf7 Mon Sep 17 00:00:00 2001 From: Scott Lowe Date: Wed, 9 Sep 2020 14:10:36 +0200 Subject: [PATCH] Improve error handling in internal scandevices Change-type: patch Connects-to: #1703 Signed-off-by: Scott Lowe --- lib/actions-oclif/internal/scandevices.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/actions-oclif/internal/scandevices.ts b/lib/actions-oclif/internal/scandevices.ts index 0d39575a..f32f5778 100644 --- a/lib/actions-oclif/internal/scandevices.ts +++ b/lib/actions-oclif/internal/scandevices.ts @@ -40,7 +40,16 @@ export default class ScandevicesCmd extends Command { public async run() { const { forms } = await import('balena-sync'); - const hostnameOrIp = await forms.selectLocalBalenaOsDevice(); - return console.error(`==> Selected device: ${hostnameOrIp}`); + try { + const hostnameOrIp = await forms.selectLocalBalenaOsDevice(); + return console.error(`==> Selected device: ${hostnameOrIp}`); + } catch (e) { + if (e.message.toLowerCase().includes('could not find any')) { + const { ExpectedError } = await import('../../errors'); + throw new ExpectedError(e); + } else { + throw e; + } + } } }