Almost all COM functions and interface methods return a value of the HRESULT (for result handle) type, so you can trap errors by creating a macro that handles any nonzero HRESULTs:
// Error handling macro for functions returning HRESULT.
#define ReturnHRIfFailed( hr ) \
{ HRESULT _hr = hr; if ( FAILED( _hr) ) return _hr; }