[Gdal-dev] GDAL CPLError and C++ Exceptions

Chapman, Martin MChapman at sanz.com
Mon Nov 27 18:25:58 EST 2006

Here ya go dude,

if (err != OGRERR_NONE) 
	throw exception(CPLGetLastErrorMsg());

Martin Chapman
Software Developer
W - 303.495.6326
C  - 303.898.0397
-----Original Message-----
From: gdal-dev-bounces at lists.maptools.org
[mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of Matt Hanson
Sent: Monday, November 27, 2006 3:25 PM
To: Gdal-dev at lists.maptools.org
Subject: [Gdal-dev] GDAL CPLError and C++ Exceptions

Hi, I recently got hung up on tracking down an GDAL error because I'm
not handling errors from CPLError.   I'd like to be able to handle those
errors and create C++ Exceptions but I'm not clear on how to do so.
Anyone have any code examples for how I might turn CPLErrors into
Exceptions?   It looks like I should probably set the error handler, but
what should that function look like?   Would it simply examine the
contents of the GDAL Error number and message and decide to throw or not
throw an exception? (which would then be presumably caught in a user's
Thanks !

Gdal-dev mailing list
Gdal-dev at lists.maptools.org

More information about the Gdal-dev mailing list