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.



39
40
41
# File 'lib/windows_error/h_result.rb', line 39

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.



44
45
46
# File 'lib/windows_error/h_result.rb', line 44

def customer?
  value >> 29 == 1
end

#facilityFacility::FacilityCode

Returns The source of the error.

Returns:



49
50
51
# File 'lib/windows_error/h_result.rb', line 49

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.



54
55
56
# File 'lib/windows_error/h_result.rb', line 54

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.



59
60
61
# File 'lib/windows_error/h_result.rb', line 59

def success?
  !failure?
end