Problem reporting the error information from an ATL component

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jaime Stuardo (jstuardo_at_manquehue.net)
Date: 12/02/04


Date: Thu, 2 Dec 2004 07:32:41 -0300

Hi all..

I need a component to send the error information to the client application
which was programmed, for example, in Visual Basic.

The interface implements ISupportErrorInfo this way:

public ISupportErrorInfoImpl<&IID_ISimuladorAPV>

and this is the method I want to report the error:

STDMETHODIMP CSimuladorAPV::GrabaAfiliado(long ID, long *pVal) {
    HRESULT hr = S_OK;
    if( m_pAfiliadoObj )
    {
        *pVal = m_pAfiliadoObj->Graba(ID);
        if( *pVal == -1 )
        {
            hr = m_pAfiliadoObj->GetLastResult();
            if( FAILED(hr) )
                Error(T2CA((LPTSTR)m_pAfiliadoObj->GetLastError()),
IID_ISimuladorAPV, hr);
            m_pAfiliadoObj->Release();
            m_pAfiliadoObj = NULL;
        }
    }
    return hr;
}

When an error occurs, Visual Basic recognizes the error code, but the error
message says that the method of ISumuladorAPV has failed.

By debugging, I know that the call to m_pAfiliadoObj->GetLastError() returns
the correct error message. Maybe the Error function doesn't make a copy of
the message so that when I call m_pAfiliadoObj->Release() the message text
is no longer valid?

Thanks

Jaime



Relevant Pages

  • Re: Absorbing an error previously set by AtlReportError?
    ... > can react appropriately and deal with it, without worrying the client. ... - the object on which this call was made implements ISupportErrorInfo ... interface whose method failed returns S_OK. ...
    (microsoft.public.vc.atl)
  • Re: What doesnt lend itself to OO?
    ... >>server is a pure data transfer interface. ... essentially exposing the client or service implementation. ... >>paradigms can be abstracted just like any other problem space in an OO ...
    (comp.object)
  • Re: Text terminal rendering design
    ... free to give it any object that satisfies that interface. ... giving it a real facade object if I choose. ... Facade to avoid touching the client. ... completely incompatible with this subsystem interface. ...
    (comp.object)
  • Re: Abstract public member variales?
    ... Entity has no encapsulation and no real methods, but the great thing about it is that its public interface will never have to change during maintenance. ... Assuming there is at most only one Property instance for each property type, then the R1 collection class would own the smarts for finding the right one. ... However, I would point out that the client of the getter is someone who needs to collaborate with a specific Property, not the Entity itself. ... The second line generates a message to the Property for the collaboration. ...
    (comp.object)
  • Re: Text terminal rendering design
    ... Which is exactly what would happen in your case when the interface of the implementation object changes. ... But then you need a new object to own the actual responsibility within the subsystem implementation. ... I can pop in a facade in a completely painless manner without being forced to rename or kludge anything. ... Facade to avoid touching the client. ...
    (comp.object)