Ignoring expected errors

This commit is contained in:
watsonb8 2020-04-13 21:16:56 -04:00
parent 34bca9c705
commit e4cc9da122

View File

@ -153,13 +153,21 @@ export class FluxAccessory implements IAccessory {
return x;
}
private isHueError = (object: any): object is HueError => {
return '_hueError' in object;
}
private setLights = async (state: LightState) => {
const promises: Array<Promise<unknown> | PromiseLike<unknown>> = [];
this._lights.map(async (light: Light) => {
try {
await this._hue.lights.setLightState(light.id, state);
} catch (err) {
this._log(`Error while setting lights: ${err}`);
if (this.isHueError(err) && err.message === "Error: parameter, xy, is not modifiable. Device is set to off.") {
//Eat this
} else {
this._log(`Error while setting lights: ${err}`);
}
}
});