diff options
| author | rr- <rr-@sakuya.pl> | 2017-01-08 11:04:21 +0100 |
|---|---|---|
| committer | rr- <rr-@sakuya.pl> | 2017-01-08 11:04:49 +0100 |
| commit | ecf347ef6eaa78697e4e361f2005e1ad843398c1 (patch) | |
| tree | a09edce875f44dfbc5a7997d07ae8574c7324642 /client/js/api.js | |
| parent | cc969a808f253c8a6e902d27c49fab3c46b27ded (diff) | |
client/api: handle expired uploads
Diffstat (limited to 'client/js/api.js')
| -rw-r--r-- | client/js/api.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/client/js/api.js b/client/js/api.js index 766e652..6f23124 100644 --- a/client/js/api.js +++ b/client/js/api.js @@ -176,9 +176,17 @@ class Api extends events.EventTarget { url, requestFactory, data, {}, options); abortFunction = () => requestPromise.abort(); return requestPromise; - }, - error => { - // TODO: check if the error is because of expired uploads + }) + .catch(error => { + if (error.response.name === + 'MissingOrExpiredRequiredFileError') { + for (let key of Object.keys(files)) { + files[key].token = null; + } + error.message = + 'The uploaded file has expired; ' + + 'please resend the form to reupload.'; + } return Promise.reject(error); }); promise.abort = () => abortFunction(); |