Module: CardController::Errors

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

Overview

controller error handling

Instance Method Summary collapse

Instance Method Details

#debug_exception?(e) ⇒ Boolean

TODO: move to exception object

Returns:

  • (Boolean)


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

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



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

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