Error code using IConversionOp.ToRasterDataset c++

534
2
11-09-2010 10:22 AM
StevePiche
New Contributor
Hello all,

I am trying to use the IConversionOp method called ToRasterDataset. The method returns me an HRESULT value of : -2147217256 ( hex: 0x80041098). I am trying to get more information regarding what exactly went wrong and I need to decrypt this error code, or find a way to get more information on why the call to the method failed.

I did find the following page that display the most common error code when programming with ESRI's COM object :

http://resources.esri.com/help/9.3/ArcGISEngine/dotnet/a3bd05c8-64a6-4dd4-acb3-0d10b021f2f8.htm

However, the error code I received is not part of them. Furthermore, the error is not part of the standards Microsoft Windows error code. The list can be found at :

http://msdn.microsoft.com/en-us/library/aa378137.aspx

Does anyone would know how I can more information explaining why the call to the method failed?

Thanks in advance,

Steve
0 Kudos
2 Replies
StevePiche
New Contributor
Found my answer.

To get a human readable error string, you should use the following snipplet :

IErrorInfoPtr ipError;
::GetErrorInfo(0,&ipError);
BSTR oBSTRError;
ipError->GetDescription(&oBSTRError);

More can be found at :
http://edndoc.esri.com/arcobjects/9.2/CPP_VB6_VBA_VCPP_Doc/COM/ExtendAO/ErrorHandling.htm

To fix my problem I needed to initialize the IRasterAnalysisEnvironmentPtr with the correct values before calling the IConversionOp.ToRasterDataset
0 Kudos
BillSmith
New Contributor III
I have routinely used the method you mentioned plus one more if it is a OS error.

//-----------------------------------------------------------------------------

BSTR
SfaUtil::getErrorInfo()
{
   // Use this for getting ESRI errors
   BSTR bError( L"Undefined" );

   IErrorInfoPtr ipError;
   ::GetErrorInfo( 0, &ipError );
   if ( ipError != 0 ) {
      ipError->GetDescription( &bError );
   }

   return bError;
}

//-----------------------------------------------------------------------------
void
SfaUtil::displayWinErr()
{
   LPVOID lpMsgBuf;
   FormatMessage(
      FORMAT_MESSAGE_ALLOCATE_BUFFER |
      FORMAT_MESSAGE_FROM_SYSTEM |
      FORMAT_MESSAGE_IGNORE_INSERTS,
      NULL,
      GetLastError(),
      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
      (LPTSTR) &lpMsgBuf,
      0,
      NULL
      );
   // Display the string.
   MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
   // Free the buffer.
   LocalFree( lpMsgBuf );
}
0 Kudos