Skip to content

Commit

Permalink
Patch unnecessary error handling from legacy code that no longer does…
Browse files Browse the repository at this point in the history
… anything
  • Loading branch information
malee31 committed Jan 8, 2025
1 parent 21ee1af commit 73f4974
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
3 changes: 2 additions & 1 deletion components/parts/utils/serverClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const STORAGE_KEYS = {
async function _fetchRetry(url, options = {}, retries = 3) {
let response = {
ok: false,
code: "fetch_failed"
status: -1,
error: "fetch_failed"
};

for(let attempt = 0; attempt < retries; attempt++) {
Expand Down
24 changes: 3 additions & 21 deletions components/parts/utils/serverClientWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import client from "./serverClient";
import config from "../../../config.json";

const SERVER_URL = config.serverURL;
const endpoints = config.serverEndpointBaseURLs;

export async function getStatus() {
Expand All @@ -17,16 +16,10 @@ export async function getStatus() {
}
};

let res;
try {
res = await client.request("GET", endpoints.getUserStatus);
} catch(err) {
result.messages.push(`Unable to fetch status. Are you connected to the internet?`);
return result;
}
const res = await client.request("GET", endpoints.getUserStatus);

if(!res.ok) {
result.messages.push(`Server behaved unexpectedly during exchange and gave this error: [${res.status}] ${res.statusText}`);
result.messages.push(`Server behaved unexpectedly during exchange and gave this error: [${res.status}] ${res.error}`);
return result;
}

Expand Down Expand Up @@ -61,18 +54,7 @@ async function signInOut(signInMode) {
});

if(!res.ok) {
result.messages.push(`Unable to fetch status. Are you connected to the internet?`);
return result;
}

if(res.status === 400) {
result.ok = true;
result.messages.push(await res.text());
return result;
}

if(!res.ok) {
result.messages.push(`Unable to sign ${signIn ? "in" : "out"}: [${res.status}] ${res.statusText}`);
result.messages.push(`Unable to get status of sign in/out: [${res.status}] ${res.error}`);
return result;
}

Expand Down

0 comments on commit 73f4974

Please sign in to comment.