处理方案脚本中的异常

时间:2018-09-29 11:57:57

标签: scheme gimp script-fu

我在Scheme中为Gimp(script-fu!)写了一个脚本。

该脚本有时需要使用真正出色的工具“ reynthesizer”。

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

现在,问题在于用户必须先安装Resynthesizer。 如果没有,他会看到类似

的讨厌的错误消息
  

错误:eval:未绑定变量:python-fu-heal-selection

我想做的是更好地处理此异常,以便用户可以知道出了什么问题。

类似的东西:

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")

但是在Scheme中。 我进行了研究,但是...在Scheme / script-fu中处理异常的记录不多...

谢谢!

1 个答案:

答案 0 :(得分:1)

GIMP使用TinyScheme,根据the documentation catch语法将捕获所有引发的错误。您正在寻找的东西是这样的:

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

这假定缺少重新合成器是任何错误的唯一原因。

相关问题