You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When deserializing a string that defines a RON struct with an optional class name that does not match the name of the Rust struct, ron::from_str returns an error that displays as Error: 1:1: Expected struct. It took me quite a long time to figure out what the issue was. It would be more helpful if the error message was something like Error: 1:1: Expected struct "Name" but got struct "ActualName".
The text was updated successfully, but these errors were encountered:
I'm also getting this error "Failed to load config: 1:1: Expected struct" in the decode_file.rs example via example.ron even when using the exact same files, not entirely sure why it's asking for a Struct.
I just had a very brief look at the codebase to see how difficult it would be to implement this. Here are my thoughts:
A simple solution would be to also report the name of the struct that was expected. This would already give most of the debugging value as you could then manually look at the RON file to see what name you provided. Implementing this option is trivial.
To find out if a different identifier was given instead, ron would have to check if any valid identifier but wrong identifier is given and that the opening ( exists. In the case where the only error is the wrong struct name, this could certainly be achieved, though at the cost of a bit of extra code clutter. However, any further edge cases would still give the original error messages.
Personally, I think that option (1) could be a good start as it provides most of the error reporting benefit already while requiring very few code changes and no additional code complexity. Option (2) could then still be implemented later on as a refinement.
When deserializing a string that defines a RON struct with an optional class name that does not match the name of the Rust struct,
ron::from_str
returns an error that displays asError: 1:1: Expected struct
. It took me quite a long time to figure out what the issue was. It would be more helpful if the error message was something likeError: 1:1: Expected struct "Name" but got struct "ActualName"
.The text was updated successfully, but these errors were encountered: