frontend/.pnpm-store/v3/files/bd/37f728c9d1978f880a2e1859d0960b4df11d3f7c7b95c8cf13b044cb66a554837265a71a6ba3f6bf51493b7eab368b6f891ca77a32a3c1d6a41f01b592e5e3

21 lines
426 B
Plaintext

import { errorObject } from './errorObject';
let tryCatchTarget: Function;
function tryCatcher(this: any): any {
errorObject.e = undefined;
try {
return tryCatchTarget.apply(this, arguments);
} catch (e) {
errorObject.e = e;
return errorObject;
} finally {
tryCatchTarget = undefined;
}
}
export function tryCatch<T extends Function>(fn: T): T {
tryCatchTarget = fn;
return <any>tryCatcher;
}