Module: Card::Format::Error

Included in:
Card::Format
Defined in:
lib/card/format/error.rb

Instance Method Summary collapse

Instance Method Details

#debug_error(e) ⇒ Object



11
12
13
# File 'lib/card/format/error.rb', line 11

def debug_error e
  raise e if Card[:debugger]&.content == "on"
end

#error_cardnameObject



15
16
17
18
19
20
21
# File 'lib/card/format/error.rb', line 15

def error_cardname
  if card&.name.present?
    card.name
  else
    I18n.t :no_cardname, scope: [:lib, :card, :format, :error]
  end
end

#rendering_error(_exception, view) ⇒ Object



23
24
25
26
# File 'lib/card/format/error.rb', line 23

def rendering_error _exception, view
  I18n.t :error_rendering, scope: [:lib, :card, :format, :error],
         cardname: error_cardname, view: view
end

#rescue_view(e, view) ⇒ Object



4
5
6
7
8
9
# File 'lib/card/format/error.rb', line 4

def rescue_view e, view
  raise e if Rails.env =~ /^cucumber|test$/
  error_view = Card::Error.exception_view @card, e
  # TODO: consider rendering dynamic error view here.
  rendering_error e, view
end