Class: WindowsError::HResult::HResultCode

Inherits:
ErrorCode
  • Object
show all
Defined in:
lib/windows_error/h_result.rb

Overview

This class extends the ErrorCode with additional HRESULT-specific attributes.

Instance Attribute Summary

Attributes inherited from ErrorCode

#description, #name, #value

Instance Method Summary collapse

Methods inherited from ErrorCode

#==, #initialize, #to_s

Constructor Details

This class inherits a constructor from WindowsError::ErrorCode

Instance Method Details

#codeInteger

Returns The error code.

Returns:

  • (Integer)

    The error code.



32
33
34
# File 'lib/windows_error/h_result.rb', line 32

def code
  value & 0xffff
end

#customer?Boolean

Returns Whether or not the value is customer-defined.

Returns:

  • (Boolean)

    Whether or not the value is customer-defined.



37
38
39
# File 'lib/windows_error/h_result.rb', line 37

def customer?
  value >> 29 == 1
end

#facilityFacility::FacilityCode

Returns The source of the error.

Returns:



42
43
44
# File 'lib/windows_error/h_result.rb', line 42

def facility
  Facility.find_by_code(value >> 16 & 0b11111)
end

#failure?Boolean

Returns Whether or not the value indicates a failure.

Returns:

  • (Boolean)

    Whether or not the value indicates a failure.



47
48
49
# File 'lib/windows_error/h_result.rb', line 47

def failure?
  value >> 31 == 1
end

#success?Boolean

Returns Whether or not the value indicates a succcess.

Returns:

  • (Boolean)

    Whether or not the value indicates a succcess.



52
53
54
# File 'lib/windows_error/h_result.rb', line 52

def success?
  !failure?
end