Exception: ViewModel::AbstractErrorWithBlame

Inherits:
AbstractError
  • Object
show all
Defined in:
lib/view_model/error.rb

Overview

For errors associated with specific viewmodel nodes, include metadata describing the node to blame.

Direct Known Subclasses

AccessControlError, DeserializationError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractError

#aggregation?, #causes, #code, #detail, #exception, #status, #title, #to_s, #view

Constructor Details

#initialize(blame_nodes) ⇒ AbstractErrorWithBlame

Returns a new instance of AbstractErrorWithBlame.



98
99
100
101
102
103
104
# File 'lib/view_model/error.rb', line 98

def initialize(blame_nodes)
  @nodes = Array.wrap(blame_nodes)
  unless @nodes.all? { |n| n.is_a?(ViewModel::Reference) }
    raise ArgumentError.new("#{self.class.name}: 'blame_nodes' must all be of type ViewModel::Reference")
  end
  super()
end

Instance Attribute Details

#nodesObject (readonly)

Returns the value of attribute nodes.



96
97
98
# File 'lib/view_model/error.rb', line 96

def nodes
  @nodes
end

Instance Method Details

#metaObject



106
107
108
109
110
# File 'lib/view_model/error.rb', line 106

def meta
  {
    nodes: format_references(nodes)
  }
end