From d8a0aa19ca77e17c27386d16999009b4e40cd090 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Mon, 20 Jan 2020 17:01:54 +0200 Subject: [PATCH] Import: fix error handling to stop the loading and print the error. --- src/Journals/ImportDialog.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Journals/ImportDialog.tsx b/src/Journals/ImportDialog.tsx index d580560..f97c0e4 100644 --- a/src/Journals/ImportDialog.tsx +++ b/src/Journals/ImportDialog.tsx @@ -106,8 +106,16 @@ class ImportDialog extends React.Component { // XXX: implement handling of rejectedFiles const reader = new FileReader(); - reader.onabort = () => alert('file reading was aborted'); - reader.onerror = () => alert('file reading has failed'); + reader.onabort = () => { + this.setState({ loading: false }); + console.error('Import Aborted'); + alert('file reading was aborted'); + }; + reader.onerror = (e) => { + this.setState({ loading: false }); + console.error(e); + alert('file reading has failed'); + }; reader.onload = () => { try { const fileText = reader.result as string;