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

hierarchy of errors #247

Closed
wants to merge 5 commits into from
Closed

Conversation

YeungOnion
Copy link
Contributor

@YeungOnion YeungOnion commented Jun 23, 2024

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.

Copy link
Contributor

@FreezyLemon FreezyLemon left a 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

Comment on lines +41 to +44
pub struct Parameters {
shape: f64,
rate: f64,
}
Copy link
Contributor

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?

Copy link
Contributor Author

@YeungOnion YeungOnion Jul 20, 2024

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.

@YeungOnion
Copy link
Contributor Author

#265 will do this without unused complexity. Thanks @FreezyLemon

@YeungOnion YeungOnion closed this Sep 6, 2024
@YeungOnion YeungOnion deleted the feat/errors branch September 13, 2024 13:38
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

Successfully merging this pull request may close these issues.

Consider improving error handling and StatsError type
2 participants