-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
CHANGE: Add error handling for propogating failures #1326
Comments
Could you please be more specific which functions you would like to return a
|
oh cool, makes sense, I'll do an evaluation of the functions I'm using & point out if there are missing safe abstractions for any... Is there an way where I can reason about which functions are safe for production & which are meant for "quick & easy" use ? |
To be fair, the last 0.8.x release is about 17 months old. We've made a bunch of changes since then for the 0.9 release but haven't given the project sufficient focus to get that done yet.
All the public API (at least, if not documented otherwise) should be safe for production use. The |
Hey, Can we fix this? |
@lsampras I think the Playground uses Rand 0.8, so If you try the current master of Rand, your example will work as expected. Since we did not have explicit tests for this, I added some in PR #1331. |
I believe everything mentioned here was addressed. Please feel free to reopen if you think |
A change request is considered a (small) Request-For-Comment, and requires a concrete proposal and motivation.
Summary
Add error handling so that functions can return errors whenever something goes wrong e.g incorrect inputs
Details
Currently this package uses asserts & unwrap's liberally, I want functions to instead return
Results
so that the callers can call the underlying functions and handle any errors that they receive.I'd like to start with a few set of commonly used public functions and add validations there which can return errors when failed...
We could later use thiserror+errorstack to build out a more graceful error handling & error stack
Motivation
What is the motivation for this change?
While unwrap's & asserts might suffice for CLI tools, when using this crate in Web applications or deployed services, especially where the input to these functions would be externallly provided... It is imperative that the application does not crash due to any weird user input...
One such case could be that we take in a lo & hi number from user & generate a random number between them using
In such scenarios it isn't the right expectation to ask the callers to validate the input for all such variants
Alternatives
Which alternatives might be considered, and why or why not?
Depend on the caller to validate all such constraints, but keeping a track of our invariants on which we assert is also tricky
The text was updated successfully, but these errors were encountered: