Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
426 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | import { errorObject } from './errorObject';
|
---|
| 2 |
|
---|
| 3 | let tryCatchTarget: Function;
|
---|
| 4 |
|
---|
| 5 | function tryCatcher(this: any): any {
|
---|
| 6 | errorObject.e = undefined;
|
---|
| 7 | try {
|
---|
| 8 | return tryCatchTarget.apply(this, arguments);
|
---|
| 9 | } catch (e) {
|
---|
| 10 | errorObject.e = e;
|
---|
| 11 | return errorObject;
|
---|
| 12 | } finally {
|
---|
| 13 | tryCatchTarget = undefined;
|
---|
| 14 | }
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | export function tryCatch<T extends Function>(fn: T): T {
|
---|
| 18 | tryCatchTarget = fn;
|
---|
| 19 | return <any>tryCatcher;
|
---|
| 20 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.