mirror of
https://github.com/mtan93/homebridge.git
synced 2026-05-09 06:16:07 +01:00
Better error handling for config.json problems
This commit is contained in:
@@ -9,11 +9,12 @@ var accessoryLoader = require('HAP-NodeJS').AccessoryLoader;
|
|||||||
|
|
||||||
console.log("Starting HomeBridge server...");
|
console.log("Starting HomeBridge server...");
|
||||||
|
|
||||||
console.log("=====================================================================");
|
console.log("_____________________________________________________________________");
|
||||||
console.log("IMPORTANT: Homebridge is in the middle of some big changes.");
|
console.log("IMPORTANT: Homebridge is in the middle of some big changes.");
|
||||||
console.log(" Read more about it here:");
|
console.log(" Read more about it here:");
|
||||||
console.log(" https://github.com/nfarina/homebridge/wiki/Migration-Guide");
|
console.log(" https://github.com/nfarina/homebridge/wiki/Migration-Guide");
|
||||||
console.log("=====================================================================");
|
console.log("_____________________________________________________________________");
|
||||||
|
console.log("");
|
||||||
|
|
||||||
// Look for the configuration file
|
// Look for the configuration file
|
||||||
var configPath = path.join(__dirname, "config.json");
|
var configPath = path.join(__dirname, "config.json");
|
||||||
@@ -28,7 +29,14 @@ if (!fs.existsSync(configPath)) {
|
|||||||
hap.init();
|
hap.init();
|
||||||
|
|
||||||
// Load up the configuration file
|
// Load up the configuration file
|
||||||
var config = JSON.parse(fs.readFileSync(configPath));
|
var config;
|
||||||
|
try {
|
||||||
|
config = JSON.parse(fs.readFileSync(configPath));
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log("There was a problem reading your config.json file:\n\n" + err.stack);
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
// pull out our custom Bridge settings from config.json, if any
|
// pull out our custom Bridge settings from config.json, if any
|
||||||
var bridgeConfig = config.bridge || {};
|
var bridgeConfig = config.bridge || {};
|
||||||
|
|||||||
Reference in New Issue
Block a user