Sha256: b0d632dc4adc7197997df7fa9612d804abbfe66f933fc64a8854b36217b834fd

Contents?: true

Size: 841 Bytes

Versions: 2

Compression:

Stored size: 841 Bytes

Contents

# -*- encoding : utf-8 -*-

class ErrorMailer
end

module ErrorMailer::BlankSlate
  def message(msg)
  end

  def exception(e)
  end
end

module ErrorMailer::Logger
  def message(msg)
    super
    App.logger.error { msg }
  end

  def exception(e)
    super
    App.logger.error{ "#{e.class}: #{e.message}\n#{e.backtrace*"\n"}" }
  end
end

module ErrorMailer::ReraiseCtrlC
  def exception(e)
    if SignalException === e || SystemExit === e
      raise e
    end
    super
  end
end

class ErrorMailer
  class << self
    include ErrorMailer::BlankSlate
    include ErrorMailer::Logger
    include ErrorMailer::ReraiseCtrlC

    def mail_message(m)
      message(m)
    end

    def mail_exception(e)
      exception(e)
    end
    
    def safe(&block)
      yield
    
    rescue => ex
      self.mail_exception(ex)
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-app-0.1.9 lib/ruby-app/error_mailer.rb
ruby-app-0.1.8 lib/ruby-app/error_mailer.rb