Add UnsupportedVersionError to improve error messaging#113
Open
erik wants to merge 3 commits intogeorust:masterfrom
Open
Add UnsupportedVersionError to improve error messaging#113erik wants to merge 3 commits intogeorust:masterfrom
erik wants to merge 3 commits intogeorust:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGELOG.mdif 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 existingGpxError::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:
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
GpxVersionexplicitly, 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!