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

[Discussion] Error instead of panic when unknown type #2

Closed
Soulou opened this issue May 1, 2014 · 1 comment
Closed

[Discussion] Error instead of panic when unknown type #2

Soulou opened this issue May 1, 2014 · 1 comment

Comments

@Soulou
Copy link

Soulou commented May 1, 2014

In the different validators, the functions panic if the type is unknown, I think it would be more go-compliant to return an error. According to me, if the type is not supported, it should be simply a validation error.

What do you thing of that?

@rselbach
Copy link
Contributor

rselbach commented May 3, 2014

The reason I did it this way is that I see the tags as being an integral
part of the struct definition and to be honest I wish I could make them
cause a syntax error at compile time if I could. Since I couldn't, I
thought they should fail as hard and soon as possible.

That said, I did this before I ended up exporting a second function that
allows rules as a function parameter, so yes, I can see how a panic might
not be appropriate there. I might have to change that.

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

2 participants