Module: PracticalErrors::Practicable

Defined in:
lib/practical_errors/practicable.rb

Instance Method Summary collapse

Instance Method Details

#arrange_exception!(exception) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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