Opened 22 years ago
Last modified 18 years ago
#288 closed enhancement (fixed)
gdal python bindings should raise exception on error conditions
Reported by: | Owned by: | warmerdam | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | default | Version: | unspecified |
Severity: | minor | Keywords: | |
Cc: |
Description
hi, I am one using mainly the python bindings and I'd like to point out one of my wishlist items: gdal.Open(filename) returns None in case of failure. But, raising an IOError exception wuold be more consistent with the python style. Similarly for other error conditions (i.e. GetDriverByName(), Driver.Create(), etc). I understand this wuold be a significant interface change, that you might be reluctant to implement. But please note that I end up doing: im = gdal.Open(filename) if im is None: raise IOError, 'Could not open "$s"' % filename quite often anyhow. Moreover, right now the gdal related code ends up being obfuscated by numerous error-handling paths needed. IMHO most of that could be avoided with the use of exceptions. thanks, alessandro
Change History (2)
comment:2 by , 18 years ago
I am closing this one for now. The next-gen SWIG bindings optionally support exceptions. You need to do gdal.UseExceptions() at the top of your script and when OGR or GDAL has an error, it will throw with the appropriate message.
Note:
See TracTickets
for help on using tickets.