Handle exception in Scheme script-fu

426 Views Asked by At

I wrote a script for Gimp (script-fu !) in Scheme.

The script calls for the really awesome tool "resynthesizer", at some point.

(python-fu-heal-selection 1 image drawable 10 0 0)

Now, the probleme is that the user has to have installed Resynthesizer before. If not, he will see a nasty error message like

Error: eval: unbound variable: python-fu-heal-selection

What I'd like to do, is handle this exception more nicely, so the user can know what is wrong.

Something like :

try
    (python-fu-heal-selection 1 image drawable 10 0 0)
catch/except/handle exception eval, or something
    (gimp-message "You have to install Resynthesizer, see the tutorial")

But in Scheme. I did my research, but... handling excptions in Scheme / script-fu is not very documented...

Thanks !

1

There are 1 best solutions below

1
On

GIMP uses TinyScheme and according to the documentation catch syntax will catch all errors thrown. What you are looking for is somthing like this:

(catch (gimp-message "You have to install Resynthesizer, see the tutorial")
  (python-fu-heal-selection 1 image drawable 10 0 0))

This assumes that missing Resynthesizer is the sole cause of any errors.