summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2014-10-10 09:19:35 +0200
committerAlex Legler <alex@a3li.li>2014-10-10 09:19:35 +0200
commitc392f6db3c5252c7036f1f2cfeb90cc853b07692 (patch)
treec9d2da6f66bbcd406163520e4850e36cf130867e
parentAdd blogs (diff)
downloadinfra-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
-rw-r--r--lib/service_registry.rb12
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