-
Notifications
You must be signed in to change notification settings - Fork 20
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
Rethinking the error management system #20
Comments
@kamyuentse :
This is because I was a clown, it was some very early code that I wrote. You may change all of this to a reasonable error type.
Some questions:
Another thing: I know of some efforts in the Rust community to streamline the handling of errors. I know of What is your opinion of this direction? Is it related to your suggestion? |
Hey @kamyuentse , What is the correct way to handle errors in the following function ? Don't bother reading the code and understanding its functionality, just take a look at its structure. request = ...pending_request_option.map_err(| | ...)?; (Notice the question mark above) Assaf |
No problem there. Some advice:
|
Currently, the
CSwitch
uses the basic handwritten Error type to manage the error, I admit that's the most flexible way, but it would make us spent more time to write the code here if we want to trace the source of the error, or we got a useless error.For example, in the
crypto
, I notice we use()
as the error in many places. But when the program runs into trouble, how to find the where is the exact location? If we leave this implementation, the caller must handle this error once the error happened, and assign a proper Error variant for it, this work should be done for each caller.Another example is the
Channeler
, in theChanneler
, we have some submodule, each of them may run into trouble. If we want to write a recoverable system, I think we should divide the error into:fatal
── we should close the whole system.recoverable
── which means that module is already broken, we should find a way restart the module, if we can't restart this module, it would be a fatal error, we should close the whole system.ignorable
── an error happened, but it does not harm the whole module. For example, infutures 0.1
, when polling a stream and it returns an Error, it doesn't mean that the stream terminated, check Consider having polling an error represent the final Stream value rust-lang/futures-rs#206 for more details.The partition above might not accurate, just my idea.
If this is reasonable, we may discuss it, and add more things here.
The text was updated successfully, but these errors were encountered: