Skip to content
Snippets Groups Projects
Unverified Commit dca56cf7 authored by Karishma Chadha's avatar Karishma Chadha Committed by GitHub
Browse files

Merge pull request #3144 from mzgoddard/allow-workspace-loading-error

log workspace update errors
parents a9243400 64c4d37e
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,7 @@ import VMScratchBlocks from '../lib/blocks';
import VM from 'scratch-vm';
import analytics from '../lib/analytics';
import log from '../lib/log.js';
import Prompt from './prompt.jsx';
import ConnectionModal from './connection-modal.jsx';
import BlocksComponent from '../components/blocks/blocks.jsx';
......@@ -300,7 +301,21 @@ class Blocks extends React.Component {
// Remove and reattach the workspace listener (but allow flyout events)
this.workspace.removeChangeListener(this.props.vm.blockListener);
const dom = this.ScratchBlocks.Xml.textToDom(data.xml);
this.ScratchBlocks.Xml.clearWorkspaceAndLoadFromXml(dom, this.workspace);
try {
this.ScratchBlocks.Xml.clearWorkspaceAndLoadFromXml(dom, this.workspace);
} catch (error) {
// The workspace is likely incomplete. What did update should be
// functional.
//
// Instead of throwing the error, by logging it and continuing as
// normal lets the other workspace update processes complete in the
// gui and vm, which lets the vm run even if the workspace is
// incomplete. Throwing the error would keep things like setting the
// correct editing target from happening which can interfere with
// some blocks and processes in the vm.
error.message = `Workspace Update Error: ${error.message}`;
log.error(error);
}
this.workspace.addChangeListener(this.props.vm.blockListener);
if (this.props.vm.editingTarget && this.state.workspaceMetrics[this.props.vm.editingTarget.id]) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment