1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-12 22:57:38 +02:00

All: Display last sync error unless it's a timeout or network error

This commit is contained in:
Laurent Cozic
2018-03-09 19:51:01 +00:00
parent 8555ecce87
commit 1acffce62d
3 changed files with 217 additions and 118 deletions

View File

@ -53,7 +53,7 @@ shim.isElectron = () => {
// Node requests can go wrong is so many different ways and with so
// many different error messages... This handler inspects the error
// and decides whether the request can safely be repeated or not.
function fetchRequestCanBeRetried(error) {
shim.fetchRequestCanBeRetried = function(error) {
if (!error) return false;
// Unfortunately the error 'Network request failed' doesn't have a type
@ -86,7 +86,7 @@ function fetchRequestCanBeRetried(error) {
if (error.code === "ETIMEDOUT") return true;
return false;
}
};
shim.fetchWithRetry = async function(fetchFn, options = null) {
const { time } = require("lib/time-utils.js");
@ -101,7 +101,7 @@ shim.fetchWithRetry = async function(fetchFn, options = null) {
const response = await fetchFn();
return response;
} catch (error) {
if (fetchRequestCanBeRetried(error)) {
if (shim.fetchRequestCanBeRetried(error)) {
retryCount++;
if (retryCount > options.maxRetry) throw error;
await time.sleep(retryCount * 3);