我正在编写一个函数,我想在输入无效时抛出异常。当我用Google搜索时,我发现有throw MyException
命令,但当我尝试使用它时:
#! /usr/bin/zsh
throw Exception
该脚本会引发以下错误:
$ ./test.sh
./test.sh:2: command not found: throw
是否存在在ZSH中抛出错误的机制?如果有的话有资源吗?
答案 0 :(得分:1)
throw
和catch
;它们不是直接构建在shell中的。
autoload throw catch
zshcontrib(1)
在EXCEPTION HANDLING
下记录了它们,尽管它们并不是很明显,它们需要加载。