utils.js 556 B

12345678910111213141516171819202122
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. //Try catch is not supported in optimizing
  4. //compiler, so it is isolated
  5. exports.errorObj = { e: {} };
  6. let tryCatchTarget;
  7. function tryCatcher(err, val) {
  8. try {
  9. const target = tryCatchTarget;
  10. tryCatchTarget = null;
  11. return target.apply(this, arguments);
  12. }
  13. catch (e) {
  14. exports.errorObj.e = e;
  15. return exports.errorObj;
  16. }
  17. }
  18. function tryCatch(fn) {
  19. tryCatchTarget = fn;
  20. return tryCatcher;
  21. }
  22. exports.tryCatch = tryCatch;