Make offline device error handling more robust.

Change-type: patch
Signed-off-by: Scott Lowe <scott@balena.io>
This commit is contained in:
Scott Lowe 2020-06-23 12:22:36 +02:00
parent 5b5f258685
commit 4656f8f11d
2 changed files with 4 additions and 2 deletions

View File

@ -65,7 +65,8 @@ export default class DeviceIdentifyCmd extends Command {
try {
await balena.models.device.identify(params.uuid);
} catch (e) {
if (e.message === 'Request error: No online device(s) found') {
// Expected message: 'Request error: No online device(s) found'
if (e.message?.toLowerCase().includes('online')) {
throw new ExpectedError(`Device ${params.uuid} is not online`);
} else {
throw e;

View File

@ -69,7 +69,8 @@ export default class DeviceShutdownCmd extends Command {
try {
await balena.models.device.shutdown(params.uuid, options);
} catch (e) {
if (e.message === 'Request error: No online device(s) found') {
// Expected message: 'Request error: No online device(s) found'
if (e.message?.toLowerCase().includes('online')) {
throw new ExpectedError(`Device ${params.uuid} is not online`);
} else {
throw e;