Module: Achoo::UI::ExceptionHandling

Included in:
Achoo, RegisterHours
Defined in:
lib/achoo/ui/exception_handling.rb

Instance Method Summary collapse

Instance Method Details

#get_exception_reason(e) ⇒ Object



16
17
18
# File 'lib/achoo/ui/exception_handling.rb', line 16

def get_exception_reason(e)
  "\nReason: \n\t" + e.message.gsub("\n", "\n\t") + "\n---\n\t" + e.backtrace.join("\n\t")
end

#handle_exception(user_message, e) ⇒ Object



7
8
9
# File 'lib/achoo/ui/exception_handling.rb', line 7

def handle_exception(user_message, e)
  Achoo::Term::warn(user_message) + get_exception_reason(e)
end

#handle_fatal_exception(user_message, e) ⇒ Object



11
12
13
14
# File 'lib/achoo/ui/exception_handling.rb', line 11

def handle_fatal_exception(user_message, e)
  puts Achoo::Term::fatal(user_message) + get_exception_reason(e)
  exit 1
end