Skip to content

Commit

Permalink
handle 504 response from service worker in offline mode for file request
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-formio committed Nov 15, 2023
1 parent 1eccbaf commit 3b06d79
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/providers/storage/xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ const XHR = {
throw err;
}
if (!response.ok) {
if (response.status === 504) {
const error = new Error('Network request failed');
error.networkError = true;
throw error;
}

const message = await response.text();
throw new Error(message || 'Unable to sign file.');
}
Expand Down Expand Up @@ -95,6 +101,11 @@ const XHR = {
if (xhr.status >= 200 && xhr.status < 300) {
resolve(serverResponse);
}
else if (xhr.status === 504) {
const error = new Error('Network request failed');
error.networkError = true;
reject(error);
}
else {
reject(xhr.response || 'Unable to upload file');
}
Expand Down

0 comments on commit 3b06d79

Please sign in to comment.