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

UnmarshalText error readability #737

Closed
thierry-f-78 opened this issue Jan 20, 2022 · 2 comments
Closed

UnmarshalText error readability #737

thierry-f-78 opened this issue Jan 20, 2022 · 2 comments
Labels
v2 Issues impacting the v2 major version.
Milestone

Comments

@thierry-f-78
Copy link

Describe the bug

I use go-toml to parse a configuration file. The parsing errors are shown by a system administrator and not by a developper.

I implement a Marshaller to Unmarshal some type (time.Duration in example). When my duration is wring, I read this message:

2| 	duration = "##fdsf"
 |             ~~~~~~~~ error calling UnmarshalText: invalid duration "##fdsf"
3| 	

The administrator read an error strating by "error calling UnmarshalText", but this string is related to program internal behavior. The administrator dont care about this information. This information could be perturbated by this information and could contact software support.

To Reproduce

https://go.dev/play/p/6YvcBbolsFu

Expected behavior

I suggest when the marshaller return a error, the error is reported as-is (without prefix).

If you're ok, I could write a PR

Versions

  • go-toml: Go playground checkouted version, I suppose the last github version fed1464
  • go: Go playground version
  • operating system: Go playground OS
@pelletier
Copy link
Owner

Sorry for the wait! I think that's a reasonable change. I am a little worried about the loss of information for a programmer who would be implementing unmarshaling for their own types, but at that point they probably know where the issue may be coming from. Feel free to open a PR!

@pelletier pelletier changed the title Error readability UnmarshalText error readability Mar 2, 2022
@pelletier pelletier added the v2 Issues impacting the v2 major version. label Mar 2, 2022
@pelletier pelletier added this to the v2.0.0-beta.7 milestone Apr 8, 2022
@pelletier
Copy link
Owner

Removed in f5cc8c4. Let me know if that doesn't work for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2 Issues impacting the v2 major version.
Projects
None yet
Development

No branches or pull requests

2 participants