aboutsummaryrefslogtreecommitdiff
path: root/src/extras/requests.js
diff options
context:
space:
mode:
authorAlystrasz <contact@remyraes.com>2022-08-09 10:59:53 +0200
committerAlystrasz <contact@remyraes.com>2022-08-09 10:59:53 +0200
commit3d9a315f31be7345b0d2ebf3a8beba55f547749b (patch)
treedb39c3f38ef1fcbcf6a0e2444470f32fc9058b6a /src/extras/requests.js
parent58b3ad7bab848f608d5b5f4f319de1da519eacd0 (diff)
parent5106d9ed409a3cc91a7755f961fab1bf91d8b7fb (diff)
downloadViper-3d9a315f31be7345b0d2ebf3a8beba55f547749b.tar.gz
Viper-3d9a315f31be7345b0d2ebf3a8beba55f547749b.zip
Merge branch 'main' into feat/ci-builds
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")] );
+ }
});
}
});