Skip to content

[enh] Add details to errors #540

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

Open
senpro-ingwersenk opened this issue Mar 5, 2025 · 0 comments
Open

[enh] Add details to errors #540

senpro-ingwersenk opened this issue Mar 5, 2025 · 0 comments

Comments

@senpro-ingwersenk
Copy link

Hello!

So, I just spent a good four hours trying to figure out why I could no longer deserialize my data into a struct and I kept getting this error here:

func ErrInvalidBeginningOfValue(c byte, cursor int64) *SyntaxError {
return &SyntaxError{
msg: fmt.Sprintf("invalid character '%c' looking for beginning of value", c),
Offset: cursor,
}
}

But actually... the error was because the field I was trying to serialize into was "an object" rather than "a string". Once I changed that (which I did because of a very random lightbulb-turns-on moment) the deserialization worked again exactly as I would have expected it to.

Finding this was ... well, let's just say my day is a little ruined. x)

Therefore I would love to propose adding more context into errors:

  • Segment that was attempted to be parsed (a range, perhaps)
  • What the value was ment to be serialized into (i.e. ...while unmarshaling %s into %T or something)
  • Probably a reminder for dumb people like me that unmarshaling is dictated by the target type (very optional though.... cough :) )

Having had a little more information on the error could've saved me a lot of troubble today - so, after my little realization, I thought I might as well put this out here as a feature request.

Thank you and kind regards!

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

No branches or pull requests

1 participant