Exception: Moxml::SerializationError

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

Overview

Error raised when serialization fails

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, node: nil, adapter: nil, format: nil) ⇒ SerializationError

Returns a new instance of SerializationError.



113
114
115
116
117
118
# File 'lib/moxml/error.rb', line 113

def initialize(message, node: nil, adapter: nil, format: nil)
  @node = node
  @adapter = adapter
  @format = format
  super(message)
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



111
112
113
# File 'lib/moxml/error.rb', line 111

def adapter
  @adapter
end

#formatObject (readonly)

Returns the value of attribute format.



111
112
113
# File 'lib/moxml/error.rb', line 111

def format
  @format
end

#nodeObject (readonly)

Returns the value of attribute node.



111
112
113
# File 'lib/moxml/error.rb', line 111

def node
  @node
end

Instance Method Details

#to_sObject



120
121
122
123
124
125
126
127
# File 'lib/moxml/error.rb', line 120

def to_s
  msg = super
  msg += "\n  Node: <#{@node.name}>" if @node.is_a?(Element) || @node.is_a?(Attribute)
  msg += "\n  Adapter: #{@adapter}" if @adapter
  msg += "\n  Format: #{@format}" if @format
  msg += "\n  Hint: Check that the node structure is valid for serialization"
  msg
end