Skip to content

fix: Add descriptive toString to ParsingException and test empty image layers - #99

Open
spydon wants to merge 2 commits into
mainfrom
fix/parsing-exception-message
Open

fix: Add descriptive toString to ParsingException and test empty image layers#99
spydon wants to merge 2 commits into
mainfrom
fix/parsing-exception-message

Conversation

@spydon

@spydon spydon commented Aug 31, 2026

Copy link
Copy Markdown
Member

Description

Closes out the two remaining parts of #92.

The crash itself (an <imagelayer> without an <image> child throwing) was already fixed in #72, where the image layer parser started using TiledImage.parseOrNull(parser) ?? const TiledImage(). This PR adds regression tests for that case in both TMX and JSON so it stays fixed.

The second complaint in the issue was that the error surfaced as Instance of 'ParsingException', which gives the user nothing to go on. ParsingException already carries name, valueFound, and reason, so this PR adds a toString() that uses them:

ParsingException: Required child missing (field: "image")
ParsingException: Not an integer (field: "width", found: "abc")

Tests cover the message format with and without a found value, and an end-to-end check that a map missing a required attribute throws a ParsingException naming that field.

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples.

Breaking Change

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

Related Issues

Fixes #92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[flame_tiled] uncaught exception with empty image layer

1 participant