-
Notifications
You must be signed in to change notification settings - Fork 26
RSDK-2758 Add an exception system #209
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
Conversation
benjirewis
left a comment
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.
I need to add test_exception.cpp with some tests, but thought I'd gather feedback before continuing.
stuqdog
left a comment
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.
(I noticed this is in draft but figured I'd take a look. If I was over-eager, apologies! Please re-request review if there's anything still coming).
One or two minor comments but looks good! Note that I expect there will be some conflict between this PR and the refactor registry PR, so we should make sure that whichever one gets merged second properly converts over any lingering runtime_exceptions.
| p->FindServiceByName(viam::component::base::v1::BaseService::service_full_name()); | ||
| if (!sd) { | ||
| throw std::runtime_error("Unable to get service descriptor for the base service"); | ||
| throw ViamException("Unable to get service descriptor for the base service"); |
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.
just a heads up that all of these "Unable to get service descriptor for {resourcetype} service" errors in {resourcetype}.cpp are being removed in the refactor-registry PR so some rebase conflict will be happening!
|
So, when this came up before (per @zaporter-work), and again now, it sends me down a deep rabbit hole of studying the gRPC error model and error_details and C++ system_error subsystem and thinking about Do we actually need sub-classes of Getting the error handling model for the SDK right is very important, because once one is adopted it is more or less impossible to change it later. On the other hand, our current informal setup is less than ideal, and maybe we shouldn't let the great be the enemy of the good, etc. |
I am definitely not an expert on this and a lot of your concerns hadn't even occurred to me so happy to be corrected, but: it seems to me we can accomplish pretty much everything we have here by carrying forward the |
|
I switched to a combination of |
acmorrow
left a comment
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.
I like where this is headed. My biggest questions are around whether this should all be in terms of error_condition rather than error_code, and whether we can do more with gRPC errors. I suspect two of my comments on that front are somewhat in tension, but that's mostly because I'm not yet 100% sure what a good solution should look like or how it should behave.
acmorrow
left a comment
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.
I like this, I think. I want to contemplate a bit how the gRPC error code and GRPCException thing should work w.r.t. to grpc::Status a bit more. Everything else here looks good though.
Probably time to promote it from draft because I expect this will merge in a form close to what is here now.
SGTM; I'll take some time to write tests in the meantime. |
acmorrow
left a comment
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.
LGTM. We have other uses of grpc in our API currently so I'm not too concerned about one more.
stuqdog
left a comment
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.
Sorry for review delay, lgtm!
022f24c to
901e15a
Compare
RSDK-2758
Redo of #100. Copied much of the base code from @zaporter-work's original implementation, and the goals of this PR remain basically the same as the last one:
Replaces all instances of
throw std::runtime_error,throw std::invalid_argument,throw std::length_errorandthrow "foo"withthrows of the new exception classes. Note that none of thethrowcalls are touched in theexamplesdirectory, as those represent example client or module code that should not be using our internal exception system.