Ensure target state errors are sent to the log backend

Closes: #1838
This commit is contained in:
Felipe Lalanne 2021-12-02 15:05:15 -03:00
parent f6692ab918
commit 445aefaa29
3 changed files with 11 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import {
ContractValidationError,
ContractViolationError,
InternalInconsistencyError,
TargetStateError,
} from './lib/errors';
import * as request from './lib/request';
@ -186,7 +187,8 @@ export async function start() {
function handleTargetUpdateError(err: any) {
if (
err instanceof ContractValidationError ||
err instanceof ContractViolationError
err instanceof ContractViolationError ||
err instanceof TargetStateError
) {
log.error(`Could not store target state for device: ${err}`);
// the dashboard does not display lines correctly,

View File

@ -22,7 +22,11 @@ import * as globalEventBus from './event-bus';
import * as hostConfig from './host-config';
import constants = require('./lib/constants');
import * as dbus from './lib/dbus';
import { InternalInconsistencyError, UpdatesLockedError } from './lib/errors';
import {
InternalInconsistencyError,
TargetStateError,
UpdatesLockedError,
} from './lib/errors';
import * as updateLock from './lib/update-lock';
import * as validation from './lib/validation';
import * as network from './network';
@ -52,7 +56,7 @@ function parseTargetState(state: unknown): TargetState {
}
const errors = ['Invalid target state.'].concat(Reporter.report(res));
throw new Error(errors.join('\n'));
throw new TargetStateError(errors.join('\n'));
}
// TODO (refactor): This shouldn't be here, and instead should be part of the other

View File

@ -81,6 +81,8 @@ export class ConfigurationValidationError extends TypedError {
export class ImageAuthenticationError extends TypedError {}
export class TargetStateError extends TypedError {}
/**
* An error thrown if our own container cannot be inspected.
* See LocalModeManager for a usage example.