init.js 788 B

1234567891011121314151617181920212223242526272829303132333435
  1. // 输入输出参数格式化
  2. input = INPUT;
  3. output = {};
  4. try {
  5. input = decodeURIComponent(input);
  6. } catch (e) { }
  7. try {
  8. input = base64.decode(input);
  9. } catch (e) { }
  10. try {
  11. input = JSON.parse(input);
  12. input = JSON.parse(input); // 解析可能存在的重复编码
  13. } catch (e) { }
  14. // 主执行阶段
  15. try {
  16. main(input, output);
  17. } catch (e) {
  18. // 错误信息输出处理,抛出 ok 表示正常结束
  19. if (e != "ok") {
  20. if (typeof (e) == "object") {
  21. output.error = e;
  22. } else if (typeof (e) == "string") {
  23. output.error = "错误:" + e;
  24. } else {
  25. output.error = JSON.stringify(e);
  26. }
  27. log.error(output.error);
  28. STATUS = "error";
  29. }
  30. }
  31. // 返回输出信息
  32. OUTPUT = output;