浏览代码

fix(request): throw on network error

Gerald 5 年之前
父节点
当前提交
4c4cbd67ff
共有 2 个文件被更改,包括 2 次插入1 次删除
  1. 1 0
      src/background/utils/update.js
  2. 1 1
      src/common/util.js

+ 1 - 0
src/background/utils/update.js

@@ -86,6 +86,7 @@ async function downloadUpdate({ props: { id }, meta, custom }) {
       return (await request(downloadURL, { headers: NO_HTTP_CACHE })).data;
     }
   } catch (error) {
+    if (process.env.DEBUG) console.error(error);
     announce(errorMessage || i18n('msgErrorFetchingUpdateInfo'), { error });
   }
   throw update;

+ 1 - 1
src/common/util.js

@@ -206,7 +206,7 @@ export async function request(url, options = {}) {
   } catch {
     result.status = -1;
   }
-  if (result.status > 300) throw result;
+  if (result.status < 0 || result.status > 300) throw result;
   return result;
 }