[Gdal-dev] Changing How GDAL Reports Errors

Pete Nagy Peter.Nagy at vexcel.com
Tue Sep 6 11:53:56 EDT 2005


It's always nice to avoid API modifications that require changes to code,
like adding a pointer to an error structure for c function calls.

Here's a possible alternative.  How about, functions return a non-zero
value to indicate an error occurred, so existing code can continue to
check for error-or-not status.  Behind the scenes, though, each function
could call something like CPLGenerateError to create an error of a
particular type and message, which would add it to a list, and return the
list index - which would be the return value for the failed function.
Therefore, any calling function that wants more information about why a
function call failed could call something like CPLGetErrorType(ret_val) or
CPLGetErrorMsg(ret_val).

Maybe this would also be easier to make thread safe, and if you plug in a
GUI to report errors to the user it would have access to errors from all
threads - wouldn't it?

Just a thought.  I've only touched the surface of GDAL and could be way
off base, but I've ported enough code to know it's usually advisable to
make things as backward compatible as possible.

-> Pete

--------------------------------------------------------------------

====================================================================
Pete Nagy                                        tel: (303) 583-0248
Vexcel Corporation                               fax: (303) 583-0246
http://www.vexcel.com                           home: (303) 823-2336
====================================================================





More information about the Gdal-dev mailing list