module Card::Format::Error
Public Instance Methods
anyone_can?(task)
click to toggle source
# File 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)
click to toggle source
# File 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)
click to toggle source
# File 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?()
click to toggle source
# File lib/card/format/error.rb, line 54 def loud_error? focal? || Card.config.raise_all_rendering_errors end
monitor_depth() { || ... }
click to toggle source
# File 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)
click to toggle source
# File 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)
click to toggle source
# File lib/card/format/error.rb, line 64 def quiet_error e, view e.report rendering_error e, view end
rendering_error(exception, view)
click to toggle source
# File lib/card/format/error.rb, line 69 def rendering_error exception, view if exception.is_a? Card::Error::UserError exception.message else t :lib_error_rendering, cardname: error_cardname(exception), view: view end end
rescue_view(e, view)
click to toggle source
# File lib/card/format/error.rb, line 41 def rescue_view e, view method = loud_error? ? :loud_error : :quiet_error send method, e, view end
view_for_denial(view, task)
click to toggle source
# File lib/card/format/error.rb, line 26 def view_for_denial view, task @denied_task = task root.error_status = 403 if focal? && voo.root? view_setting(:denial, view) || :denial end
view_for_unknown(setting_view)
click to toggle source
# File lib/card/format/error.rb, line 17 def view_for_unknown setting_view if main? && voo.root? root.error_status = 404 :not_found else setting_view || :unknown end end