Module: Card::Format::Error
- Included in:
- Card::Format
- Defined in:
- card/lib/card/format/error.rb
Instance Method Summary collapse
-
#anyone_can?(task) ⇒ Boolean
-
#error_cardname(_exception) ⇒ Object
-
#loud_error(e, view) ⇒ Object
-
#loud_error? ⇒ Boolean
-
#monitor_depth ⇒ Object
-
#ok?(task) ⇒ Boolean
-
#quiet_error(e, view) ⇒ Object
-
#rendering_error(exception, view) ⇒ Object
-
#rescue_view(e, view) ⇒ Object
-
#view_for_denial(view, task) ⇒ Object
-
#view_for_unknown(setting_view) ⇒ Object
Instance Method Details
#anyone_can?(task) ⇒ Boolean
9 10 11 12 13 14 15 |
# File 'card/lib/card/format/error.rb', line 9 def anyone_can? task return false unless task.is_a? Symbol @anyone_can ||= {} @anyone_can[task] = card.anyone_can? task if @anyone_can[task].nil? @anyone_can[task] end |
#error_cardname(_exception) ⇒ Object
46 47 48 49 50 51 52 |
# File 'card/lib/card/format/error.rb', line 46 def error_cardname _exception if card&.name.present? safe_name else ::I18n.t :lib_no_cardname end end |
#loud_error(e, view) ⇒ Object
58 59 60 61 62 |
# File 'card/lib/card/format/error.rb', line 58 def loud_error e, view e.report if focal? && voo.root? card.errors.add "#{view} view", rendering_error(e, view) if card.errors.empty? raise e end |
#loud_error? ⇒ Boolean
54 55 56 |
# File 'card/lib/card/format/error.rb', line 54 def loud_error? focal? || Card.config.raise_all_rendering_errors end |
#monitor_depth ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'card/lib/card/format/error.rb', line 32 def monitor_depth max = Card.config.max_depth if depth >= max || voo.depth >= max raise Card::Error::UserError, t(:format_too_deep) end yield end |
#ok?(task) ⇒ Boolean
4 5 6 7 |
# File 'card/lib/card/format/error.rb', line 4 def ok? task task = :create if task == :update && card.new_card? card.ok? task end |
#quiet_error(e, view) ⇒ Object
64 65 66 67 |
# File 'card/lib/card/format/error.rb', line 64 def quiet_error e, view e.report rendering_error e, view end |
#rendering_error(exception, view) ⇒ Object
69 70 71 72 73 74 75 |
# File 'card/lib/card/format/error.rb', line 69 def rendering_error exception, view if exception.is_a? Card::Error::UserError exception. else t :lib_error_rendering, cardname: error_cardname(exception), view: view end end |
#rescue_view(e, view) ⇒ Object
41 42 43 44 |
# File 'card/lib/card/format/error.rb', line 41 def rescue_view e, view method = loud_error? ? :loud_error : :quiet_error send method, e, view end |