diff options
author | Alex Legler <alex@a3li.li> | 2014-10-10 09:19:35 +0200 |
---|---|---|
committer | Alex Legler <alex@a3li.li> | 2014-10-10 09:19:35 +0200 |
commit | c392f6db3c5252c7036f1f2cfeb90cc853b07692 (patch) | |
tree | c9d2da6f66bbcd406163520e4850e36cf130867e /lib/service_registry.rb | |
parent | Add blogs (diff) | |
download | infra-status-c392f6db3c5252c7036f1f2cfeb90cc853b07692.tar.gz infra-status-c392f6db3c5252c7036f1f2cfeb90cc853b07692.tar.bz2 infra-status-c392f6db3c5252c7036f1f2cfeb90cc853b07692.zip |
Improve exception handling
This avoids all-UNKNOWN NAME displays in the event a missing nagios
status is requested
Diffstat (limited to 'lib/service_registry.rb')
-rw-r--r-- | lib/service_registry.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/service_registry.rb b/lib/service_registry.rb index c6d208a..3d560b9 100644 --- a/lib/service_registry.rb +++ b/lib/service_registry.rb @@ -92,7 +92,14 @@ class ServiceRegistry def service(name, &block) @services[name] = {} @services[name][:name] = @next_name || name - @services[name][:status] = block.call + + begin + @services[name][:status] = block.call + rescue Exception => e + @services[name][:status] = State::NA + $stderr.puts e + end + @next_name = nil end @@ -113,7 +120,8 @@ class ServiceRegistry load(File.join(File.dirname(__FILE__), '..', 'data', 'services.rb')) @load_date = DateTime.now @cache_locked = false - rescue Exception + rescue Exception => e + $stderr.puts e @services = {} @load_date = DateTime.new(2000, 1, 1) @cache_locked = false |