Improve error handling in internal scandevices

Change-type: patch
Connects-to: #1703
Signed-off-by: Scott Lowe <scott@balena.io>
This commit is contained in:
Scott Lowe 2020-09-09 14:10:36 +02:00
parent d7007721a7
commit 9f8569e33f

View File

@ -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;
}
}
}
}