Exception: Moxml::AttributeError

Inherits:
Error
  • Object
show all
Defined in:
lib/moxml/error.rb

Overview

Error raised when attribute operations fail

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, name: nil, element: nil, value: nil) ⇒ AttributeError

Returns a new instance of AttributeError.



153
154
155
156
157
158
# File 'lib/moxml/error.rb', line 153

def initialize(message, name: nil, element: nil, value: nil)
  @attribute_name = name
  @element = element
  @value = value
  super(message)
end

Instance Attribute Details

#attribute_nameObject (readonly)

Returns the value of attribute attribute_name.



151
152
153
# File 'lib/moxml/error.rb', line 151

def attribute_name
  @attribute_name
end

#elementObject (readonly)

Returns the value of attribute element.



151
152
153
# File 'lib/moxml/error.rb', line 151

def element
  @element
end

#valueObject (readonly)

Returns the value of attribute value.



151
152
153
# File 'lib/moxml/error.rb', line 151

def value
  @value
end

Instance Method Details

#to_sObject



160
161
162
163
164
165
166
167
# File 'lib/moxml/error.rb', line 160

def to_s
  msg = super
  msg += "\n  Attribute: #{@attribute_name}" if @attribute_name
  msg += "\n  Element: <#{@element.name}>" if @element.is_a?(Element)
  msg += "\n  Value: #{@value.inspect}" if @value
  msg += "\n  Hint: Verify attribute name follows XML naming rules"
  msg
end