Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More detailed deserialization error messages? #245

Open
markolbert opened this issue Mar 31, 2017 · 5 comments
Open

More detailed deserialization error messages? #245

markolbert opened this issue Mar 31, 2017 · 5 comments

Comments

@markolbert
Copy link

Is there a way to get more detailed deserialization errors? When there's a problem with the model I'm trying to deserialize into (e.g., I've defined a property as a string when it needs to be a collection of strings), I'm generally reduced to commenting out all but one property in the target model, running the program, see if the exception occurs, rinse & repeat.

Perhaps some form of logging facility? Or is one already built in?

@aaubry
Copy link
Owner

aaubry commented Mar 31, 2017

The exception should indicate the line number and line offset of the error, as well as a message explaining the error. What additional information would be helpful to you ?

@markolbert
Copy link
Author

What would help me is the name of the property being bound to, because so far most of the errors have been associated with defining the target property incorrectly. For example:

public class TestTarget
{
[YamlMember(Alias = "property1"]
public string Property1 {get; set;}
}

yaml file:

property1
- some text

This will fail because Property1 should've been declared as a collection of strings, not a single string. But knowing the line and column where the error took place in the code isn't as helpful as knowing which target property failed to initialize.

If the target property name was included in the exception message it would be helpful.

Apologies if this info is already present and I'm just not seeing it.

@aaubry
Copy link
Owner

aaubry commented Apr 1, 2017

I see what you mean. I agree that this information would be useful. It shouldn't be too hard to add that information. I'll see what can be done.

@ajhmain
Copy link

ajhmain commented Nov 7, 2019

@aaubry This issue is important. Please report the actual property name that cannot be deserialized on error. I wasted 30 mins investigating a failed deserialization because the line/char number are inaccurate and do not point to the actual property. Instead they seem to point to the 'parent' line of the failed property (the line beginning/after the -) which in this case was many lines above the actual problem.
All you need to do is report the name of the actual property/properties in the exception message.

@davidnduffy
Copy link

Any progress on this?
I would really appreciate this info also in a project I am working on.
Thank-you

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

No branches or pull requests

4 participants