Skip to content

Add UnsupportedVersionError to improve error messaging#113

Open
erik wants to merge 3 commits intogeorust:masterfrom
erik:erik/unsupported-version-error
Open

Add UnsupportedVersionError to improve error messaging#113
erik wants to merge 3 commits intogeorust:masterfrom
erik:erik/unsupported-version-error

Conversation

@erik
Copy link
Copy Markdown

@erik erik commented Feb 1, 2026

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGELOG.md if knowledge of this change could be valuable to users.

This PR adds a GpxError::UnsupportedVersionError(String) variant to represent the case of trying to parse a file with a version unsupported by this library. Similar to the existing GpxError::UnknownVersionError(crate::types::GpxVersion), but this allows the actual problematic version to be inspected.

Motivation here is that I noticed some fairly unhelpful error messages when using this library to parse my GPX files:

unknown GPX version: Unknown

Somehow, I had some GPX files from the future on version 8.0.

The current error type takes an enum version parameter, so it can't represent what the unknown value actually is, and will always be constructed with GpxVersion::Unknown.

Maybe a bit redundant to have both (and open to suggestions on better naming!), but I think it makes sense to keep the original error in the write-path since the user passes a GpxVersion explicitly, and to avoid a breaking API change.


Also, I realize it's in poor form to have opened this without an accompanying issue. In this case it took roughly the same amount of time to sketch an implementation as it would have to open an issue. Feel free to close this if it's not desired!

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.

1 participant