Skip to content

Commit

Permalink
feat(accessories): request error logging
Browse files Browse the repository at this point in the history
- improve logging of request errors
- less log clutter
- make use of the improved logger in 0721678
  • Loading branch information
johannrichard committed Nov 28, 2020
1 parent 0721678 commit f936ae8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/lib/dingzDaBaseAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,22 @@ export class DingzDaBaseAccessory {
if (e.isAxiosError) {
switch (e.code) {
case 'ECONNABORTED':
this.log.error('Connection aborted --> ' + e.config.url);
this.log.error(
'HTTP ECONNABORTED Connection aborted --> ' + this.device.address,
);
this.isReachable = false;
break;
case 'EHOSTDOWN':
this.log.error('HTTP EHOSTDOWN Host down --> ' + this.device.address);
this.isReachable = false;
break;
default:
this.log.error(
`HTTP ${e.code} ${e.message} ${e.response?.statusText ?? ' '}--> ` +
this.device.address,
);
break;
}
this.log.error('HTTP Response Error in --> ' + e.config.url);
this.log.error(e.code ?? 'NOERRCODE');
this.log.error(e.message);
this.log.error(e.stack ?? '<No stack>');
this.log.error(e.response?.data);
this.log.error(e.response?.statusText ?? '');
} else if (e instanceof DeviceNotReachableError) {
this.log.error(
`handleRequestErrors() --> ${this.device.name} (${this.device.address})`,
Expand Down

0 comments on commit f936ae8

Please sign in to comment.