Module: Card::Format::Error
- Included in:
- Card::Format
- Defined in:
- lib/card/format/error.rb
Instance Method Summary collapse
- #error_cardname(_exception) ⇒ Object
- #focal_error(e, view) ⇒ Object
- #rendering_error(exception, view) ⇒ Object
- #rescue_view(e, view) ⇒ Object
Instance Method Details
#error_cardname(_exception) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/card/format/error.rb', line 13 def error_cardname _exception if card&.name.present? safe_name else I18n.t :no_cardname, scope: %i[lib card format error] end end |
#focal_error(e, view) ⇒ Object
21 22 23 24 |
# File 'lib/card/format/error.rb', line 21 def focal_error e, view card.errors.add "#{view} view", rendering_error(e, view) if card.errors.empty? raise e end |
#rendering_error(exception, view) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/card/format/error.rb', line 26 def rendering_error exception, view if exception.is_a? Card::Error::UserError exception. else tr :error_rendering, scope: [:lib, :card, :format, :error], cardname: error_cardname(exception), view: view end end |
#rescue_view(e, view) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/card/format/error.rb', line 4 def rescue_view e, view # make config option; don't refer directly to env raise e if Rails.env =~ /^cucumber$/ # TODO: unify with Card::Error#report Rails.logger.info "#{e.}\n#{e.backtrace}" method = focal? ? :focal_error : :rendering_error send method, e, view end |