Dear developers,
i am confused about the implementation of grass.error() and
grass.fatal() in the grass.scripting library.
From my understanding should the grass.error() function simply print
an error and grass.fatal() should either exit or call an exception so
that the GUI or a module developer can catch a fatal error. The
grass.set_raise_on_error() function allow to throw an exception in
case an error occurs that is not fatal to the processing. But it is
not possible to catch a fatal error because simply exit is called.
Can grass.fatal() be catched when raise_on_error is true, since it
calls internally grass.error()? If yes raise_on_error must be set by
the GUI to catch fatal error. BUT all errors that may not be fatal for
module processing will raise an exception too?
That gives me the impression that grass.fatal() should never be called
in a Python library function since otherwise the GUI will crash?
Howto implement library functions that face an error but should allow
i.e. the GUI to keep on processing? Printing an error and raise a
ScriptError exception should do it i guess. But what to do in cases
the same library functions are used in modules where the error should
be handled as fatal? Raising an exception will in this case confuse
the user, hence calling fatal would be more appropriate. IMHO Python
modules should show the same behavior as the C and bash modules and
avoid to print implementation language specific errors.
Hence i would like to add a "raise_on_fatal_error" flag to catch
grass.fatal() errors by exception and to avoid the raise of a script
error by calling grass.error().
What do you think? Any suggestions are welcome.
Best regards
Soeren