[Qgis-developer] segfault python: no catch for QgsException?

Martin Dobias wonder.sk at gmail.com
Mon Dec 7 12:18:43 EST 2009


On Mon, Nov 30, 2009 at 2:49 PM, Martin Dobias <wonder.sk at gmail.com> wrote:
>
> Looking at the QgsProject class, the only methods that throw
> exceptions are read() and write(). Both currently either return true
> on success or end up throwing an exception. So we could remove the
> usage of exceptions without a lot of fuss just by returning false on
> error and adding a method to return error type (or error message).
> This would be actually a tiny change in API semantics, but I think
> it's worth it (considering that python plugins have trouble with
> dealing the exceptions).
>
>> If there is a good alternative, we could make it a task for people who want
>> to start cpp (like me and Werner...) maybe?
>
> Well... I can try, it might be a good excercise - depends on how much
> c++ knowledge you've acquired already :-) Anyway I think I'll might
> find some time during 1.4 bugfixing period to do the changes... if
> there are no objections against the proposal from other devs.

A short follow up note: I've removed the usage of exceptions within
QgsProject in r12349 and r12350.
Now you should be able to do something like this:

if !QgsProject.instance().read():
  print "Error:", QgsProject.instance().error()


Martin


More information about the Qgis-developer mailing list