Exception: Moxml::ValidationError
- Defined in:
- lib/moxml/error.rb
Overview
Error raised when XML validation fails
Instance Attribute Summary collapse
-
#constraint ⇒ Object
readonly
Returns the value of attribute constraint.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(message, node: nil, constraint: nil, value: nil) ⇒ ValidationError
constructor
A new instance of ValidationError.
- #to_s ⇒ Object
Constructor Details
#initialize(message, node: nil, constraint: nil, value: nil) ⇒ ValidationError
Returns a new instance of ValidationError.
53 54 55 56 57 58 |
# File 'lib/moxml/error.rb', line 53 def initialize(, node: nil, constraint: nil, value: nil) @node = node @constraint = constraint @value = value super() end |
Instance Attribute Details
#constraint ⇒ Object (readonly)
Returns the value of attribute constraint.
51 52 53 |
# File 'lib/moxml/error.rb', line 51 def constraint @constraint end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
51 52 53 |
# File 'lib/moxml/error.rb', line 51 def node @node end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
51 52 53 |
# File 'lib/moxml/error.rb', line 51 def value @value end |
Instance Method Details
#to_s ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/moxml/error.rb', line 60 def to_s msg = super # Only add extra details if any were provided has_details = (@node.is_a?(Element) || @node.is_a?(Attribute)) || @constraint || @value if has_details msg += "\n Node: <#{@node.name}>" if @node.is_a?(Element) || @node.is_a?(Attribute) msg += "\n Constraint: #{@constraint}" if @constraint msg += "\n Value: #{@value.inspect}" if @value msg += "\n Hint: Ensure the value meets XML specification requirements" end msg end |