So far I have not found anything to help me ease the debugging experience of the ESRI COMException
, and therefore decided to try and do something about it. I put the solution on gist.github.com for everybody to use.
I used the resource ArcObjects error codes and copied all the error messages with codes and enums into a text file, about 1900+ lines. Not all exceptions are documented even, and many are just to generic to get anything useful out of.
The "enums" look like this CADASTRAL_E_OPERATION_FAILED
, with a regex I then picked out "the first word the underscore and then the second word" CADASTRAL_E
as that seemed to be a common pattern that i could group the error codes by per assembly/namespace
I then filled a second text file with the shortened enums and the belonging assemblies/namespaces
.
When that was done I created a console project, where i read all the lines from the two files and with an algorithm created a Dictionary
with the namespaces
as key
, and the value
as a second Dictionary
where the key
was the 10 digit error code
, and the value
as an EsriError
class containing the message etc.
In the end I then wrote out the code as a Dictionary initializer
to a new text file by iterating over the Dictionaries
, and then copied the code into my project.
Since the COMException.Source
attribute sais which assembly/namespace
the error was thrown in,
I can use that to lookup the Dictionary
containing all the error codes for that assembly.
To find the correct message to go with the error code i then do a lookup in the retrieved dictionary with the COMException.ErrorCode
as the key
, and then I either get back the error message or an message telling me that the ComExceptionInterpreter
had no message associated with the error code.
Hope this will help somebody, and if anybody have anything to add, let me know!
You can also fork the gist to make it your own.
ESRI Error Lookup Utility