[geos-devel] Exception Issues
Norman Vine
nhv at cape.com
Tue May 27 08:52:50 EDT 2003
Martin Davis writes:
>
> Well, IMO the optimal sequence of fixes to try is:
>
> 1. Fix the compiler/linker/PostgresQL to eliminate the problem
> with aborting on exceptions in loaded libraries.
> 2. Hack GEOS to eliminate or optionalize (love that word!) the exceptions.
>
IMO I am not sure we really have any problem other then that
** C++ is not JAVA ** and GEOS is a very much an attempt at
a literal translation of a JAVA library to C++ where the underlying
JAVA machine handles much of what the C++ programmer has
to handle explicitly as is to be expected with a 'lower level' interface
to the 'bits themselves' there is some confusion as to how to handle
C++ exceptions, which are NOT the same thing as JAVA exceptions
Disclaimer I usually do not use the C++ exception mechanism
so buyer beware..
That said now that we have all of the PostGIS GEOS interaction
in a C++ not a C library we should be able to handle any "standard"
exception thrown by the GEOS code by including it within an appropriate
try block
i.e
#include <exception>
#include <iostream>
#include <geos/util.h>
int wrapped_GEOS_CALL(..)
{
try
{
GEOS_CALL(..);
}
// catch unhandled GEOS exceptions
catch (GEOSException& ge)
{
std::cout << "GEOS Exception :" << ge.toString() <<std::endl;
return X;
}
// Catch other unhandled standard exceptions
catch ( std::exception& e)
{
std::cout << "Standard Exception: " << e.what() << std::endl;
return X;
}
return(0);
}
Note this does nothing to try to ensure that the underlying
machine is left in an appropriate state for further computing
which I believe the JAVA machine will try to do for you
HTH
Norman
More information about the geos-devel
mailing list