Import Dialog: log potential import errors to console and close dialog.

master
Tom Hacohen 5 years ago
parent 3ef5c0c5e2
commit 0dffd71276

@ -108,6 +108,7 @@ class ImportDialog extends React.Component<PropsType> {
reader.onabort = () => alert('file reading was aborted'); reader.onabort = () => alert('file reading was aborted');
reader.onerror = () => alert('file reading has failed'); reader.onerror = () => alert('file reading has failed');
reader.onload = () => { reader.onload = () => {
try {
const fileText = reader.result as string; const fileText = reader.result as string;
const items = itemsCreator(fileText); const items = itemsCreator(fileText);
@ -134,6 +135,15 @@ class ImportDialog extends React.Component<PropsType> {
this.props.onClose(); this.props.onClose();
} }
}); });
} catch (e) {
console.error(e);
alert('An error has occurred, please contact developers.');
if (this.props.onClose) {
this.setState({ loading: false });
this.props.onClose();
}
throw e;
}
}; };
this.setState({ loading: true }); this.setState({ loading: true });

Loading…
Cancel
Save