Permalink
Browse files

catch various exceptions

  • Loading branch information...
1 parent c0a65a5 commit 28d3afdb8736d3d40bfd7a897f7937be19f03f83 @joshbuddy committed May 26, 2010
Showing with 13 additions and 4 deletions.
  1. +10 −3 lib/messed/em_runner.rb
  2. +3 −1 lib/messed/interface/adapter/twitter_search.rb
View
@@ -28,9 +28,16 @@ def initialize(options, &block)
logger.info "Starting..." unless options[:supress_banner]
if options[:detach]
pid = EM.fork_reactor do
- trap("INT") { EM.stop_reactor_loop }
- EM.run do
- EM.next_tick(&block)
+ begin
+ trap("INT") { EM.stop_reactor_loop }
+ EM.run do
+ EM.next_tick(&block)
+ end
+ rescue Exception
+ logger.error "FATAL ERROR #{$!.message}"
+ logger.error $!.backtrace.join("\n")
+ EM.stop_reactor_loop
+ exit(1)
end
end
Process.detach(pid)
@@ -44,7 +44,9 @@ def start
start
end
}
- rescue RuntimeError
+ rescue Exception
+ logger.error $!.message
+ logger.error $!.backtrace.join("\n")
EM.add_timer(interface.configuration.options[:interval]) do
start
end

0 comments on commit 28d3afd

Please sign in to comment.