更新时间:2023-03-03 GMT+08:00
调试
本章节介绍调试、日志代码的规则。
- try、catch
不需要做统一异常处理时,都不用写try、catch语句,只需抛出统一的错误码。
【推荐】:
if (input.customerId == "") { context.throwError("STO-001003"); };
【不推荐】:
if (input.customerId == "") { context.setError('STO-001003', 'You have not login or the session has expired, please login again.'); return; };
- 打印日志(Console.log())
- 最终归档时,脚本不要有调试代码。
父主题: 脚本开发规范