-
Notifications
You must be signed in to change notification settings - Fork 13
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
Improve existing error handling #46
base: master
Are you sure you want to change the base?
Conversation
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.
PR looks good hopefully we can get Circle CI working, and look a little more at why that test is failing at that point when it should be failing during the transmission if anything.
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.
a good step toward improving error handling! however, I want to make some high-level comments rather than leaving many smaller, more specific comments.
while utp
probably leans too heavily on the std::io::Error
, a lot of the errors introduced here are quite granular. for example, whether or not a send on some internal channel failed or succeeded should not go to the user. that is an internal implementation detail, and we do not want to have to change the error enum if we change the internals. the user should see that something failed, and a low-level log message could indicate the specific issue.
another such example is an invalid packet from the remote peer. the user does not need a granular/specific error about what aspect of the packet was invalid, but only an error that indicates that the remote peer misbehaved according to the protocol. a log message would indicate the specific aspect of the invalid packet.
we should represent what we can with std::io::Error
and be conservative in the new errors that we define (that are exposed to the user), so that those errors are meaningful to the user (e.g. have too many connections) and do not reflect internal implementation details. if other relevant internal failures are not visible, then we can add logs.
I disagree with you, debugging this crate without knowing where in the code the error originates from is much more time consuming. As you can see, mostly the errors I added wrap the io error you chose. In a few places, I think you have chosen the wrong error based on what you wish the program to mean and not what it actually means, for example in the on_timeout function, actually what fails here is a counter that you have implemented and that important piece of information is abstracted away as you chose the io error |
Just leaving my 2 cents here...
vs.
imo this library is not "production" / still in alpha. that being so, the focus should be in aiding developers not users. improving the debugging process > ux. once the library is production ready, these errors can be revisited to improve the ux. a tracking issue to revisit the errors could be helpful so that we can move forward with these improvements in the meanwhile, even at the temporary expense of ux. |
I'm not sure which point you disagree with. and I don't understand why you need to define all of these new errors to see where the error occurs in like I said above, I see that
I would reiterate that I think we can achieve your desired improvements to debugging ability in a simpler way. if you are only going to end up logging whatever errors we define here anyway, then we can emit those within the library code. we can introduce new errors where those errors could conceivably influence application behavior. |
Who is this "consumer" you're referencing to @jacobkaufmann? Please back your argument with some facts so I can better understand your firm standpoint, which is against mine and @njgheorghita's standpoint. uTP is a transport protocol, the user of a transport protocol will always be a developer. Additional to that fact, a non-developer user wouldn't be able to make more sense of some io error than any other error, in general only devs use command line tools anyway.
Language agnostic practice is such that any place where execution of the program stops, an error should be thrown. Anywhere an error occurs but the code should continue executing, the error is written to a log owned by the program. What are you basing your standpoint on that "we don't need to represent all possible errors at the level of specificity you have here"?
Why is it up to the application using uTP to handle uTPs errors in a way that is meaningful to the consumer=developer? A reminder that it is very seldom you propagate |
when I say "user" or "consumer" I mean developer i.e. a user/consumer of the library. sorry for the confusion. but I want to refocus the discussion here. I want to reiterate that I see that |
When the program panics, what does it matter how verbose the error is that is thrown? The program execution stops, I think that is what bothers the developer most. I would even say that enabling log for level 'error' shouldn't show these errors that make the program panic, they should only show the errors that don't make the program panic. I am debugging the program now, and I don't think the |
I agree with jacob. The errors this library returns are meant for the user expecting the library to be bug free. As demostrated by me finding the overflow bug in #60 in the expainer I show how you can get a |
Propagates existing errors from where they are created to the call that triggered them to allow for easy debugging.
Included Nick's test in this issue #44 as a test in stream.rs