Thursday, November 15, 2012

How to decode and interpret ESRI error codes?

How to decode and interpret ESRI error codes?:

ESRI Error codes are HRESULTs. This is true for ArcObjects programming and also for the ESRI Open FileGDB API (and thus, all open source projects that consume this API like GDAL or QGIS can potentially return these error codes).

Very often, I see that people (devs or users) run into, say, error code 0x80040653 and have no idea of what it means. Let’s interpret them.

First step is to always get an unsigned int32 value our of whatever you have. I usually keep this python script to help me convert from hex to int32

def int32(x):
if x>0xFFFFFFFF:
raise OverflowError
if x>0x7FFFFFFF:
x=int(0x100000000-x)
if x<2147483648:
return -x
else:
return -2147483648
return x


In other languages it is even easier (just cast it).

So using my method above, I get:

   >>> int32(0x80040653)
-2147219885


ESRI has several enums that contain error codes. The problem, is that there is not a “master” error enum since every single programming team at ESRI maintains their own list/enum.

Armed with this information, I head over to the ESRI site to figure out which Error enum contains this error. In this case, it is clearly between the range of fdoErrors which leads me to find this:

FDO_E_FIELD_NOT_FOUND   
-2147219885
An expected Field was not found or could not be retrieved properly.


Yep, some required field is missing. Now I know what went wrong.


DIGITAL JUICE

No comments:

Post a Comment

Thank's!