Exception: Moxml::DocumentStructureError

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

Overview

Error raised when document structure is invalid

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message, operation: nil, state: nil) ⇒ DocumentStructureError

Returns a new instance of DocumentStructureError.



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

def initialize(message, operation: nil, state: nil)
  @attempted_operation = operation
  @current_state = state
  super(message)
end

Instance Attribute Details

#attempted_operationObject (readonly)

Returns the value of attribute attempted_operation.



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

def attempted_operation
  @attempted_operation
end

#current_stateObject (readonly)

Returns the value of attribute current_state.



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

def current_state
  @current_state
end

Instance Method Details

#to_sObject



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

def to_s
  msg = super
  msg += "\n  Operation: #{@attempted_operation}" if @attempted_operation
  msg += "\n  Current State: #{@current_state}" if @current_state
  msg += "\n  Hint: Ensure the document structure follows XML specifications"
  msg
end