Class: ExceptionMaster
- Inherits:
-
Object
- Object
- ExceptionMaster
- Defined in:
- lib/exception_master.rb
Instance Attribute Summary collapse
-
#email_config ⇒ Object
readonly
Returns the value of attribute email_config.
Instance Method Summary collapse
-
#initialize(raise_error: true, deliver_email: true, email_config: {}) ⇒ ExceptionMaster
constructor
A new instance of ExceptionMaster.
- #watch ⇒ Object
Constructor Details
#initialize(raise_error: true, deliver_email: true, email_config: {}) ⇒ ExceptionMaster
Returns a new instance of ExceptionMaster.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/exception_master.rb', line 8 def initialize(raise_error: true, deliver_email: true, email_config: {}) @email_config = { via: :sendmail, from: 'exception-master@localhost', subject: 'Error' } @email_config.merge!(email_config) @raise_error = raise_error @deliver_email = deliver_email if @email_config[:to].nil? raise "Please specify email addresses of email recipients using :to key in email_config attr (value should be array)" end end |
Instance Attribute Details
#email_config ⇒ Object (readonly)
Returns the value of attribute email_config.
6 7 8 |
# File 'lib/exception_master.rb', line 6 def email_config @email_config end |
Instance Method Details
#watch ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/exception_master.rb', line 21 def watch yield rescue Exception => e if @deliver_email Pony.mail(@email_config.merge({html_body: error_to_html(e)})) end raise(e) if @raise_error end |