fix: handle "failed to fetch" errors better

This commit is contained in:
thecodrr
2022-07-08 12:07:26 +05:00
parent 8ce71917a3
commit d7d21bc54b
3 changed files with 7 additions and 7 deletions

View File

@@ -17,17 +17,18 @@ class Monographs {
} }
async init() { async init() {
const user = await this._db.user.getUser();
const token = await this._db.user.tokenManager.getAccessToken();
if (!user || !token || !user.isEmailConfirmed) return;
let monographs = await this._db.storage.read("monographs", true);
try { try {
const user = await this._db.user.getUser();
const token = await this._db.user.tokenManager.getAccessToken();
if (!user || !token || !user.isEmailConfirmed) return;
let monographs = await this._db.storage.read("monographs", true);
monographs = await http.get(`${Constants.API_HOST}/monographs`, token); monographs = await http.get(`${Constants.API_HOST}/monographs`, token);
await this._db.storage.write("monographs", monographs); await this._db.storage.write("monographs", monographs);
if (monographs) this.monographs = monographs;
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
if (monographs) this.monographs = monographs;
} }
/** /**

View File

@@ -206,7 +206,7 @@ class UserManager {
return await this.getUser(); return await this.getUser();
} }
} catch (e) { } catch (e) {
console.error(e); console.error("Error fetching user", e);
return await this.getUser(); return await this.getUser();
} }
} }

View File

@@ -34,6 +34,5 @@ export const getServerNameFromHost = (host) => {
"Subscriptions Management Server", "Subscriptions Management Server",
[extractHostname(hosts.ISSUES_HOST)]: "Bug Reporting Server", [extractHostname(hosts.ISSUES_HOST)]: "Bug Reporting Server",
}; };
console.log(names, host);
return names[host]; return names[host];
}; };