Skip to content

Commit

Permalink
Clearer error message when Homebridge cannot create/read/write cache …
Browse files Browse the repository at this point in the history
…directory
  • Loading branch information
ACDR committed Oct 16, 2020
1 parent 340488c commit e89b16d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"license": "UNLICENSED",
"displayName": "Yamaha AVR",
"name": "homebridge-yamaha-avr",
"version": "2.0.1",
"version": "2.0.2",
"description": "homebridge-plugin - Add a Yamaha AVR as a HomeKit Audio Receiver with Power, Input, Volume & Remote Control",
"author": {
"name": "ACDR",
Expand Down
16 changes: 12 additions & 4 deletions src/accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,17 @@ export class YamahaAVRAccessory {

async init() {
try {
await storage.init({
dir: this.platform.config.cacheDirectory || '../.node_persist',
});
try {
await storage.init({
dir: this.platform.config.cacheDirectory || '../.node_persist',
});
} catch(err) {
this.platform.log.error(`
Could not create cache directory.
Please check your Homebridge instance has permission to read/write to "${err.path}"
or set a different cache directory using the "cacheDirectory" config property.
`);
}

await this.createTVService();
await this.createTVSpeakerService();
Expand Down Expand Up @@ -298,7 +306,7 @@ export class YamahaAVRAccessory {
} catch (err) {
reject(`
Could not write to cache.
Please check your Homebridge instance has permission to access "${this.platform.config.cacheDirectory || '../.node-persist'}"
Please check your Homebridge instance has permission to write to "${this.platform.config.cacheDirectory || '../.node-persist'}"
or set a different cache directory using the "cacheDirectory" config property.
`);
}
Expand Down

0 comments on commit e89b16d

Please sign in to comment.