[Gdal-dev] Exception class(es) in SWIG C# wrapper

Tamas Szekeres szekerest at gmail.com
Tue Mar 6 16:33:32 EST 2007

> That's interesting. Are you saying that any time there is an error, an
> exception will be thrown? I obviously haven't done enough testing yet to
> have tried a failure case.
> Also worth noting is that Microsoft (and others) recommend against using
> ApplicationException, and especially deriving from it. A search will find
> many resources, but here is one:
> http://blogs.msdn.com/kcwalina/archive/2006/06/23/644822.aspx

It seems to me that this is yet another place where Microsoft could
not give an obvious guideline that's not to be sneezed at. In the
beginnings the usage of ApplicationException was recommended to be
used for the non CLR originated errors, but in some point it have been
misused (by Microsoft) and therefore the original intents have been
This gives me the impression that many of the proposals should not be
taken so seriously or we should wait for at least 2 years before
utilizing such suggestions.

> > Apparently this is a similar operation you have described
> > above. In my understanding the main difference is that you
> > would want to get a different exception type for the
> > different modules.
> That's not really what I meant. It wouldn't really matter if there is a
> single exception type for both GDAL and OGR or separate ones, although since
> they are in different namespaces, the exception would need to be at the root
> OSGeo or one would have to reference the other.
> My main point is rather than throwing a generic exception type
> (System.Exception or System.ApplicationException), having a GDAL/OGR
> exception type would enable the exception handlers to intelligently process
> errors from GDAL/OGR differently than all other exceptions of type
> System.Exception. This is not always necessary, but very powerful if
> available.

The current implementation is the default behaviour how the interface
handles the exceptions. In exchange for some divergence from the other
bindings is could be customized in many ways, but at this time I
cannot see the smashing benefit to do so.

Best regards,


More information about the Gdal-dev mailing list