-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Poco::DateTime uses assertions for validation #1540
Comments
Yes. Throwing Poco::InvalidArgumentException would be appropriate. |
Thanks! Sorry I never got around to this, something more urgent came up. Meanwhile, I read about narrow vs wide contracts [1] and started to think that maybe the That said, Poco strikes me as trying to avoid undefined behavior for the most part, so an exception seems more in style. Let me know what you prefer. |
For what little it's worth, I'd prefer that the constructor validates and throws on error. Whichever way it's done, in a library like Poco, there should be some way for the caller to verify that DateTime is doing what they expect it to do. |
The bug is still in 1.13.3 |
We're unit-testing some code based on
Poco::DateTime
.When we throw invalid dates at our code, this is printed to the console:
It turns out because
DateTime
usespoco_assert
for validation, there doesn't seem to be a clean way to validate date times without double-checking them.Would you consider patches to throw a documented exception type instead? Any ideas on which type is preferable? Just a Poco::Exception?
The text was updated successfully, but these errors were encountered: