Class: Object

Inherits:
BasicObject
Defined in:
lib/error_log/core_ext.rb

Instance Method Summary collapse

Instance Method Details

#catch_error(category = 'catch_error', options = {}) ⇒ Object

Handy way to catch exceptions



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/error_log/core_ext.rb', line 5

def catch_error(category='catch_error', options={})
   raise "no block given!" unless block_given?
   begin
      yield
      return false
   rescue Exception => e
      ErrorLog.log(options[:level] || :error, e.to_str,
         :backtrace => e.backtrace,
         :params => options[:params],
         :category => category)
   end
end