From 0fa4c4b2ed88e6e3532ecc3914ecb2e1492af8ab Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford <7019101+cwillisf@users.noreply.github.com> Date: Tue, 15 Sep 2020 14:52:08 -0700 Subject: [PATCH] handle initial project load errors --- src/renderer/app.jsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/renderer/app.jsx b/src/renderer/app.jsx index 0e73fff..1fe1a37 100644 --- a/src/renderer/app.jsx +++ b/src/renderer/app.jsx @@ -1,4 +1,4 @@ -import {ipcRenderer, shell} from 'electron'; +import {ipcRenderer, remote, shell} from 'electron'; import bindAll from 'lodash.bindall'; import omit from 'lodash.omit'; import PropTypes from 'prop-types'; @@ -70,11 +70,19 @@ const ScratchDesktopHOC = function (WrappedComponent) { }, e => { this.props.onLoadingCompleted(); - console.error(e); // TODO: dialog box reporting the error? - - // abandon this load and instead fetch+load the default project - // WARNING: this stuff doesn't currently work correctly! this.props.onLoadedProject(this.props.loadingState, false); + remote.dialog.showMessageBox(remote.getCurrentWindow(), { + type: 'error', + title: 'Failed to load project', + message: 'Invalid or corrupt project file.', + detail: e.message + }); + + // this effectively sets the default project ID + // TODO: maybe setting the default project ID should be implicit in `requestNewProject` + this.props.onHasInitialProject(false, this.props.loadingState); + + // restart as if we didn't have an initial project to load this.props.onRequestNewProject(); } );