Class: AutoError::AppError
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AutoError::AppError
- Defined in:
- app/models/auto_error/app_error.rb
Class Method Summary collapse
- .add_context(env, opts) ⇒ Object
- .clear_context!(env) ⇒ Object
- .context(env) ⇒ Object
- .log!(env, exception, opts, data = {}) ⇒ Object
Class Method Details
.add_context(env, opts) ⇒ Object
37 38 39 |
# File 'app/models/auto_error/app_error.rb', line 37 def add_context( env, opts ) context(env).merge!( opts ) end |
.clear_context!(env) ⇒ Object
44 45 46 |
# File 'app/models/auto_error/app_error.rb', line 44 def clear_context!( env ) env['auto_error.app_error.context'] = {} end |
.context(env) ⇒ Object
40 41 42 43 |
# File 'app/models/auto_error/app_error.rb', line 40 def context( env ) env['auto_error.app_error.context'] ||= {} env['auto_error.app_error.context'] end |
.log!(env, exception, opts, data = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/auto_error/app_error.rb', line 13 def self.log!( env, exception, opts, data={} ) opts[:data] = data opts[:data].merge! self.context(env) opts.merge!( { klass: exception.class.name, message: exception., backtrace: ( exception.backtrace ? clean_backtrace(exception.backtrace) : [] ).join("\n") } ) app_error = create!( opts ) if AutoError::Config.email_on_error.any? begin send_email!( env, exception, opts[:data] ) rescue $stderr.puts "AutoError failed to send exception notification email to #{AutoError::Config.email_on_error.inspect} -- #{$!.inspect}" end end app_error end |