Promise.prototype.handle = function()

in src/service/helper.ts [53:64]


Promise.prototype.handle = function <T>(fallback?: T, reasonMsg?: string, isDialog?: boolean) {
  const self = this;
  return new Promise(async (resolve) => {
    try {
      const value: T = await self; resolve(value);
    } catch (e) {
      resolve(fallback);
      const msg = handleError(e as Error, reasonMsg);
      isDialog && alert(msg);
    }
  });
};