Skip to content

fix: improve error response when loading XML#3545

Merged
cwillisf merged 1 commit intodevelopfrom
fix/xml-load-diagnostics
Apr 14, 2026
Merged

fix: improve error response when loading XML#3545
cwillisf merged 1 commit intodevelopfrom
fix/xml-load-diagnostics

Conversation

@cwillisf
Copy link
Copy Markdown
Contributor

@cwillisf cwillisf commented Apr 14, 2026

Resolves

Improves, but does not fix, #3543

See also scratchfoundation/scratch-editor#528

Proposed Changes

When domToWorkspace throws, wrap the error with context listing the top-level XML elements that were being loaded. This makes it much easier to diagnose which block or element caused the failure.

Also move setGroup(false) and setResizesEnabled(true) into a finally block so they are always called, even when loading fails. Previously setGroup(true) was never closed, and setResizesEnabled(true) was skipped on error.

Test Coverage

NA - this is just about providing better feedback in error cases

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves diagnostics and cleanup behavior when loading workspace XML fails, by wrapping Blockly.Xml.domToWorkspace errors with additional context and ensuring workspace resize + event grouping state is restored even on failure.

Changes:

  • Wrap domToWorkspace failures with an error message that includes top-level block/shadow element identifiers.
  • Ensure Blockly.Events.setGroup(false) and workspace.setResizesEnabled(true) always run via a finally block.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/xml.ts Outdated
Comment thread src/xml.ts Outdated
Comment thread src/xml.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/xml.ts Outdated
Comment thread tests/browser/xml.test.ts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/xml.ts Outdated
Comment thread tests/browser/xml.test.ts Outdated
…omXml

When domToWorkspace throws, wrap the error with context listing the
top-level XML elements that were being loaded. This makes it much
easier to diagnose which block or element caused the failure.

Also move setGroup(false) and setResizesEnabled(true) into a finally
block so they are always called, even when loading fails. Previously
setGroup(true) was never closed, and setResizesEnabled(true) was
skipped on error.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cwillisf cwillisf merged commit 960aeaf into develop Apr 14, 2026
8 checks passed
@cwillisf cwillisf deleted the fix/xml-load-diagnostics branch April 14, 2026 22:50
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants