37f728c9d1978f880a2e1859d0960b4df11d3f7c7b95c8cf13b044cb66a554837265a71a6ba3f6bf51493b7eab368b6f891ca77a32a3c1d6a41f01b592e5e3 426 B

1234567891011121314151617181920
  1. import { errorObject } from './errorObject';
  2. let tryCatchTarget: Function;
  3. function tryCatcher(this: any): any {
  4. errorObject.e = undefined;
  5. try {
  6. return tryCatchTarget.apply(this, arguments);
  7. } catch (e) {
  8. errorObject.e = e;
  9. return errorObject;
  10. } finally {
  11. tryCatchTarget = undefined;
  12. }
  13. }
  14. export function tryCatch<T extends Function>(fn: T): T {
  15. tryCatchTarget = fn;
  16. return <any>tryCatcher;
  17. }