Module: CardController::Errors

Included in:
CardController
Defined in:
lib/card_controller/errors.rb

Overview

controller error handling

Defined Under Namespace

Modules: Rescue

Instance Method Summary collapse

Instance Method Details

#debug_exception?(e) ⇒ Boolean

TODO: move to exception object

Returns:

  • (Boolean)


27
28
29
30
31
32
# File 'lib/card_controller/errors.rb', line 27

def debug_exception? e
  !e.is_a?(Card::Error::UserError) &&
    !e.is_a?(ActiveRecord::RecordInvalid) &&
    Card::Codename[:debugger] &&
    Card[:debugger]&.content =~ /on/  # && !Card::Env.ajax?
end

#handle_exception(exception) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/card_controller/errors.rb', line 18

def handle_exception exception
  raise exception if debug_exception?(exception)

  @card ||= Card.new
  error = Card::Error.report exception, card
  show error.class.view, error.class.status_code
end