aboutsummaryrefslogtreecommitdiff
path: root/src/extras/requests.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/extras/requests.js')
-rw-r--r--src/extras/requests.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/extras/requests.js b/src/extras/requests.js
index 16b1330..7509e9e 100644
--- a/src/extras/requests.js
+++ b/src/extras/requests.js
@@ -2,6 +2,7 @@ const { app } = require("electron");
const path = require("path");
const fs = require("fs");
const { https } = require("follow-redirects");
+const lang = require("../lang");
// all requests results are stored in this file
@@ -58,6 +59,11 @@ async function getLatestNsVersion() {
_saveCache(cache);
resolve( cache[NORTHSTAR_LATEST_RELEASE_KEY]["body"]["tag_name"] );
});
+ })
+
+ .on('error', () => {
+ console.error('Failed to get latest Northstar version.');
+ resolve( false );
});
}
});
@@ -103,6 +109,20 @@ async function getNsReleaseNotes() {
_saveCache(cache);
resolve( cache[NORTHSTAR_RELEASE_NOTES_KEY]["body"] );
});
+ })
+
+ // When GitHub cannot be reached (when user doesn't have Internet
+ // access for instance), we return latest cache content even if
+ // it's not up-to-date, or display an error message if cache
+ // is empty.
+ .on('error', () => {
+ if ( cache[NORTHSTAR_RELEASE_NOTES_KEY] ) {
+ console.warn("Couldn't fetch Northstar release notes, returning data from cache.");
+ resolve( cache[NORTHSTAR_RELEASE_NOTES_KEY]["body"] );
+ } else {
+ console.error("Couldn't fetch Northstar release notes, cache is empty.");
+ resolve( [lang("request.northstar.noReleaseNotes")] );
+ }
});
}
});
@@ -140,6 +160,20 @@ async function getVpReleaseNotes() {
_saveCache(cache);
resolve( cache[VIPER_RELEASE_NOTES_KEY]["body"] );
});
+ })
+
+ // When GitHub cannot be reached (when user doesn't have Internet
+ // access for instance), we return latest cache content even if
+ // it's not up-to-date, or display an error message if cache
+ // is empty.
+ .on('error', () => {
+ if ( cache[VIPER_RELEASE_NOTES_KEY] ) {
+ console.warn("Couldn't fetch Viper release notes, returning data from cache.");
+ resolve( cache[VIPER_RELEASE_NOTES_KEY]["body"] );
+ } else {
+ console.error("Couldn't fetch Viper release notes, cache is empty.");
+ resolve( [lang("request.viper.noReleaseNotes")] );
+ }
});
}
});