Use typed error to report inspection problems

This will throw a typed error in case when supervisor cannot inspect
its own container.

Change-type: patch
Signed-off-by: Roman Mazur <roman@balena.io>
This commit is contained in:
Roman Mazur 2019-07-23 12:44:35 +03:00
parent 4846acb25e
commit 4b56022d93
No known key found for this signature in database
GPG Key ID: 9459886EFE6EE2F6
2 changed files with 8 additions and 1 deletions

View File

@ -62,3 +62,9 @@ export class ConfigurationValidationError extends TypedError {
}
export class ImageAuthenticationError extends TypedError {}
/**
* An error thrown if our own container cannot be inspected.
* See LocalModeManager for a usage example.
*/
export class SupervisorContainerNotFoundError extends TypedError {}

View File

@ -5,6 +5,7 @@ import * as _ from 'lodash';
import Config from './config';
import Database from './db';
import * as constants from './lib/constants';
import { SupervisorContainerNotFoundError } from './lib/errors';
import log from './lib/supervisor-console';
import { Logger } from './logger';
@ -176,7 +177,7 @@ export class LocalModeManager {
);
return this.collectContainerResources(fallback);
}
throw e;
throw new SupervisorContainerNotFoundError(e);
}
}