[Gdal-dev] CPLErrorV change to better support scriptland
Frank Warmerdam
fwarmerdam at gmail.com
Sun Jun 19 21:46:38 EDT 2005
On 6/19/05, Kevin Ruland <kruland at ku.edu> wrote:
> Frank,
>
> One of the things Shawn expressed dissatisfaction from was for some
> problems, gdal will abort() and the interpreter would go away very
> quickly. This of course, is not very nice behavour.
>
> The problem is very apparent in the NG swig code because I don't do any
> special parameter checking prior to calling the underlying method. So
> for example, say "out.tif" only contains one layer, then if I do this:
>
> f = gdal.Open( 'out.tif' )
> f.GetRasterBand(42)
>
> The underlying GDALDataset::GetRasterBand() gets the numer 42 with no
> prior checking. It rightfually decides this is a good time to issue a
> CPLError( CE_Fatal,....). The problem is CPLErrorV will call abort() if
> the error class is CE_Fatal. Bye bye python.
>
> I see that in the old bindings, you place extra checks in the script
> side for the parameters. This is not very amenable to supporting
> multiple bindings.
>
> Is there any way to remove this abort() entirely and leave it up to the
> application to decide if a problem is serious enough to abort? It just
> seems more polite but I don't understand what the implications would be.
Kevin,
I'm not really keen on removing the abort() for fatal errors, but
I do think that this particular error should be changed to just
a normal CE_Failure error intsead of a fatal error. Really the
only use I see currently for the fatal error is when CPLMalloc()
fails in an allocation.
I will change GDALDataset::GetRasterBand() to issue a
CE_Failure error and return NULL in case of an illegal input.
This can be then translated into an appropriate type of exception
in python and possibly other languages.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list