-
Notifications
You must be signed in to change notification settings - Fork 84
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
hierarchy of errors #247
hierarchy of errors #247
Conversation
mostly doing this to test out handling errors this way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty nice. The error contains a lot of information (maybe too much? I can't estimate if this level of detail is needed) and the source annotation from thiserror
should create better dev feedback for little effort.
There's one thing I don't really understand but I like this in general
pub struct Parameters { | ||
shape: f64, | ||
rate: f64, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why you added this abstraction? You could also check the parameters inside Gamma::new
and return a suitable error from there, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly just playing around with having input checking in another type to support the use of infallible new
methods.
But more interestingly perhaps it could be a way to get alternative parametrizations #198 as well as new_from_moments
to do something like,
let m = Gamma::new(shape, rate).into_moments();
let p = Poisson::new_from_moments(m);
But I've lots of thoughts floating around about that none motivated by something I've actually needed thus far, so happy to drop it until specific need arises. As a solution to #198 could be adding just one more method.
#265 will do this without unused complexity. Thanks @FreezyLemon |
looking for some feedback on possible error hierarchy.
I don't think I did the source error pattern nicely, but I think there's something here worth looking at.