From fc209f64deff7a2793980d11ee738f7140c444cf Mon Sep 17 00:00:00 2001 From: Ramires Viana <59319979+ramiresviana@users.noreply.github.com> Date: Wed, 4 May 2022 12:36:13 +0000 Subject: [PATCH] fix: network error object message --- frontend/src/api/files.js | 4 ++-- frontend/src/api/utils.js | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/api/files.js b/frontend/src/api/files.js index 49077123..7b885cfa 100644 --- a/frontend/src/api/files.js +++ b/frontend/src/api/files.js @@ -111,8 +111,8 @@ export async function post(url, content = "", overwrite = false, onupload) { } }; - request.onerror = (error) => { - reject(error); + request.onerror = () => { + reject(new Error("001 Connection aborted")); }; request.send(bufferContent || content); diff --git a/frontend/src/api/utils.js b/frontend/src/api/utils.js index 4319e8ff..549a74ec 100644 --- a/frontend/src/api/utils.js +++ b/frontend/src/api/utils.js @@ -18,8 +18,11 @@ export async function fetchURL(url, opts) { }, ...rest, }); - } catch (error) { - return { status: 0 }; + } catch { + const error = new Error("000 No connection"); + error.status = 0; + + throw error; } if (res.headers.get("X-Renew-Token") === "true") {