Class: LiveIdentity::Identity::ExtendedError

Inherits:
Object
  • Object
show all
Defined in:
lib/live_identity.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identity) ⇒ ExtendedError

Returns a new instance of ExtendedError.

Raises:



542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
# File 'lib/live_identity.rb', line 542

def initialize(identity)
    @Category = nil
    @Error = nil
    @ErrorBlob = nil
    @ErrorBlobXML = nil
    hIdentity = identity.hIdentity
    pdwCategory = FFI::MemoryPointer.new(:PDWORD)
    pdwError = FFI::MemoryPointer.new(:PDWORD)
    pszErrorBlob = FFI::MemoryPointer.new(:LPWSTR)
    hr = IDCRL.GetExtendedError(hIdentity, nil, pdwCategory, pdwError, pszErrorBlob)
    raise LiveIdentityError.new(hr) if LiveIdentity::IsError?(hr)
    @Category = pdwCategory.read_uint
    @Error = pdwError.read_uint
    @ErrorBlob = read_wide_string(pszErrorBlob.read_pointer)
    @ErrorBlobXML = Nokogiri::XML(@ErrorBlob)
    LiveIdentity::FreeMemory(pszErrorBlob.read_pointer)
end

Instance Attribute Details

#CategoryObject (readonly)

Returns the value of attribute Category.



538
539
540
# File 'lib/live_identity.rb', line 538

def Category
  @Category
end

#ErrorObject (readonly)

Returns the value of attribute Error.



539
540
541
# File 'lib/live_identity.rb', line 539

def Error
  @Error
end

#ErrorBlobObject (readonly)

Returns the value of attribute ErrorBlob.



540
541
542
# File 'lib/live_identity.rb', line 540

def ErrorBlob
  @ErrorBlob
end

#ErrorBlobXMLObject (readonly)

Returns the value of attribute ErrorBlobXML.



541
542
543
# File 'lib/live_identity.rb', line 541

def ErrorBlobXML
  @ErrorBlobXML
end

Instance Method Details

#BlobResponseObject



560
561
562
563
# File 'lib/live_identity.rb', line 560

def BlobResponse
    return unless @ErrorBlobXML
    @BlobResponse ||= Nokogiri::XML(@ErrorBlobXML.xpath('/IDCRLErrorInfo/Response').first.content)
end

#BlobResponseErrorObject



565
566
567
568
569
570
571
572
573
574
# File 'lib/live_identity.rb', line 565

def BlobResponseError
    response = BlobResponse()
    reasonText        = response.xpath('//S:Fault/S:Reason/S:Text').first.content
    errorValue        = response.xpath('//S:Fault/S:Detail/psf:error/psf:value').first.content.strip.to_i(16)
    internalError     = response.xpath('//S:Fault/S:Detail/psf:error/psf:internalerror/psf:code').first.content.strip.to_i(16)
    internalErrorText = response.xpath('//S:Fault/S:Detail/psf:error/psf:internalerror/psf:text').first.content.strip
    "ReasonText:    #{reasonText}\n" +
    "ErrorValue:    #{WinCommon::Errors::HRESULT::GetNameCode(errorValue)}\n" +
    "InternalError: #{internalErrorText} #{WinCommon::Errors::HRESULT::GetNameCode(internalError)}\n"
end

#to_sObject



576
577
578
579
# File 'lib/live_identity.rb', line 576

def to_s
    "Category:      #{IDCRL::IDCRL_ERROR_CATEGORY.to_h[@Category]} (#{@Category})\n" +
    "Error:         #{WinCommon::Errors::HRESULT::GetNameCode(@Error)}\n" + BlobResponseError()
end