Error Handling

In the code shown so far in this chapter, errors trapped by the smart pointer wrapper functions have resulted in _com_issue_errorex being called. This has displayed the HRESULT generated by the offending call. The problem, though, is that some of the smart pointer wrapper functions attempt to continue execution and use invalid interface pointers. For example, here is the wrapper function for Connection::Execute:

inline _RecordsetPtr _Connection::Execute (
       _bstr_t CommandText,
       VARIANT * RecordsAffected, long Options )
{
  struct _Recordset * _result;
  HRESULT _hr = raw_Execute(CommandText,
      RecordsAffected, Options, &_result);
  if (FAILED(_hr))
    _com_issue_errorex(_hr, this, __uuidof(this));
  return _RecordsetPtr(_result, false);
}

Get Windows® CE 3.0 Application Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.