Method: Canis::App#safe_loop

Defined in:
lib/canis/core/util/app.rb

#safe_loop(&block) ⇒ Object

if calling loop separately better to call this, since it will shut off ncurses and print error on screen. UNUSED



185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/canis/core/util/app.rb', line 185

def safe_loop &block
  begin
    loop &block
  rescue => ex
    $log.debug( "APP.rb rescue reached ")
    $log.debug( ex) if ex
    $log.debug(ex.backtrace.join("\n")) if ex
  ensure
    close
    # putting it here allows it to be printed on screen, otherwise it was not showing at all.
    if ex
      puts "========== EXCEPTION =========="
      p ex 
      puts "==============================="
      puts(ex.backtrace.join("\n")) 
    end
  end
end