在大型 JSL 项目中,使用 Include() 调用进行错误处理的最佳实践是什么?I'm working on a large JSL project that uses many Include() calls to organize the code. I've run into an issue where if one of the included scripts fails, the main script continues executing, which can lead to cascading errors or unexpected behavior.
目前,我正在考虑重构我的包含文件结构,使其仅包含函数定义而非可执行代码。这样做的目的是,如果某个包含文件在定义阶段失败,后续对这些函数的调用将会更明确地失败。
不过,我想知道是否有更好的方法来处理这种情况。具体来说:
- Is there a way to make
Include() halt execution if the included script encounters an error?
- 将函数定义与可执行代码分离是否是推荐的做法,或者对于大型 JSL 项目是否有其他更合适的架构模式?
我想了解其他人是如何构建 JSL 项目以稳健地处理依赖项的。
自动化和脚本编写回复:大型 JSL 项目中使用 Include() 调用时,错误处理的最佳实践是什么?我认为一种方法是用 Try() 函数包裹你的 include 语句。
test1.jsl
Names Default To Here(1);
show
test2.jsl
Names Default To Here(1);
Try(
Include("test1.jsl");
,
Throw(Char(exception_msg));
);<BR /><BR />Show("not executed");<BR />