From ecf347ef6eaa78697e4e361f2005e1ad843398c1 Mon Sep 17 00:00:00 2001 From: rr- Date: Sun, 8 Jan 2017 11:04:21 +0100 Subject: [PATCH] client/api: handle expired uploads --- client/js/api.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/client/js/api.js b/client/js/api.js index 766e6525..6f231245 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();