Class: WinRM::PSRP::MessageData::ErrorRecord

Inherits:
Base
  • Object
show all
Defined in:
lib/winrm/psrp/message_data/error_record.rb

Overview

error record message type

Instance Attribute Summary

Attributes inherited from Base

#raw

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from WinRM::PSRP::MessageData::Base

Instance Method Details

#docObject



42
43
44
# File 'lib/winrm/psrp/message_data/error_record.rb', line 42

def doc
  @doc ||= REXML::Document.new(raw)
end

#error_category_messageObject



34
35
36
# File 'lib/winrm/psrp/message_data/error_record.rb', line 34

def error_category_message
  @error_category_message ||= string_prop('ErrorCategory_Message')
end

#error_details_script_stack_traceObject



38
39
40
# File 'lib/winrm/psrp/message_data/error_record.rb', line 38

def error_details_script_stack_trace
  @error_details_script_stack_trace ||= string_prop('ErrorDetails_ScriptStackTrace')
end

#exceptionObject



22
23
24
# File 'lib/winrm/psrp/message_data/error_record.rb', line 22

def exception
  @exception ||= property_hash('Exception')
end

#fully_qualified_error_idObject



26
27
28
# File 'lib/winrm/psrp/message_data/error_record.rb', line 26

def fully_qualified_error_id
  @fully_qualified_error_id ||= string_prop('FullyQualifiedErrorId')
end

#invocation_infoObject



30
31
32
# File 'lib/winrm/psrp/message_data/error_record.rb', line 30

def invocation_info
  @invocation_info ||= property_hash('InvocationInfo')
end

#property_hash(prop_name) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/winrm/psrp/message_data/error_record.rb', line 51

def property_hash(prop_name)
  prop_nodes = REXML::XPath.first(doc, "//*[@N='#{prop_name}']/Props")
  prop_nodes.elements.each_with_object({}) do |node, props|
    name = node.attributes['N']
    props[underscore(name).to_sym] = node.text if node.text
  end
end

#string_prop(prop_name) ⇒ Object



46
47
48
49
# File 'lib/winrm/psrp/message_data/error_record.rb', line 46

def string_prop(prop_name)
  prop = REXML::XPath.first(doc, "//*[@N='#{prop_name}']")
  prop.text if prop
end

#underscore(camel) ⇒ Object



59
60
61
62
63
64
# File 'lib/winrm/psrp/message_data/error_record.rb', line 59

def underscore(camel)
  camel.gsub(/::/, '/')
       .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
       .gsub(/([a-z\d])([A-Z])/, '\1_\2')
       .tr('-', '_').downcase
end