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



40
41
42
# File 'lib/winrm/psrp/message_data/error_record.rb', line 40

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

#error_category_messageObject



32
33
34
# File 'lib/winrm/psrp/message_data/error_record.rb', line 32

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

#error_details_script_stack_traceObject



36
37
38
# File 'lib/winrm/psrp/message_data/error_record.rb', line 36

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

#exceptionObject



20
21
22
# File 'lib/winrm/psrp/message_data/error_record.rb', line 20

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

#fully_qualified_error_idObject



24
25
26
# File 'lib/winrm/psrp/message_data/error_record.rb', line 24

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

#invocation_infoObject



28
29
30
# File 'lib/winrm/psrp/message_data/error_record.rb', line 28

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

#property_hash(prop_name) ⇒ Object



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

def property_hash(prop_name)
  prop_nodes = REXML::XPath.first(doc, "//*[@N='#{prop_name}']/Props")
  return {} if prop_nodes.nil?

  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



44
45
46
47
# File 'lib/winrm/psrp/message_data/error_record.rb', line 44

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