module PracticalErrors::Practicable

Public Instance Methods

arrange_exception!(exception) click to toggle source
# File lib/practical_errors/practicable.rb, line 5
    def arrange_exception!(exception)
      @customised_message = ''

      append_header

      abstract_original_message(exception)

      if PracticalErrors::ErrorAdvisers::const_defined?(exception.class.to_s)
        @customised_message << PracticalErrors::ErrorAdvisers::const_get(exception.class.to_s).advise(exception)
      else
        @customised_message << <<-"EOS".strip_heredoc
          hmm... I don't know this error :(
          Tell me => https://github.com/serihiro/practical_errors
        EOS
      end

      append_footer

      exception.message.gsub!(/.+/, @customised_message)
    end

Private Instance Methods

abstract_original_message(exception) click to toggle source
# File lib/practical_errors/practicable.rb, line 44
    def abstract_original_message(exception)
      original_message = exception.message
      @customised_message << <<-"EOS".strip_heredoc

          Rails says, "#{original_message}".

      EOS
    end
append_header() click to toggle source
# File lib/practical_errors/practicable.rb, line 28
    def append_header
      @customised_message << <<-EOS.strip_heredoc

        ========== Practical Errors appends message from here ==========
      EOS
    end