summaryrefslogtreecommitdiff
path: root/lib/oxidized/config.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/config.rb')
-rw-r--r--lib/oxidized/config.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/oxidized/config.rb b/lib/oxidized/config.rb
index 9c2faff..02698a6 100644
--- a/lib/oxidized/config.rb
+++ b/lib/oxidized/config.rb
@@ -1,6 +1,7 @@
module Oxidized
require 'asetus'
class NoConfig < OxidizedError; end
+ class InvalidConfig < OxidizedError; end
class Config
Root = File.join ENV['HOME'], '.config', 'oxidized'
Crash = File.join Root, 'crash'
@@ -39,8 +40,13 @@ module Oxidized
'juniper' => 'junos',
}
- CFGS.load # load system+user configs, merge to Config.cfg
- CFG = CFGS.cfg # convenienence, instead of Config.cfg.password, CFG.password
+ begin
+ CFGS.load # load system+user configs, merge to Config.cfg
+ rescue => error
+ raise InvalidConfig, "Error loading config: #{error.message}"
+ ensure
+ CFG = CFGS.cfg # convenienence, instead of Config.cfg.password, CFG.password
+ end
Log.level = Logger::INFO unless CFG.debug
raise NoConfig, 'edit ~/.config/oxidized/config' if CFGS.create