-
Notifications
You must be signed in to change notification settings - Fork 26
RSDK-2758 Consistent error handling & exception scheme #100
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
| try { | ||
| this->fix_api(); | ||
| } catch (std::string err) { // NOLINT | ||
| throw err; | ||
| } |
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.
Does this do something that I don't understand?
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.
Probably not! Looks like the try/catch is pretty much meaningless there, and catching a str is just an artifact of poor initial design decisions. Makes sense to remove.
| // TODO(RSDK-1742) Replace throwing of strings with throwing of | ||
| // runtime_error | ||
| throw "Unable to establish connecting path!"; |
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.
Ticket was marked as completed
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.
This is great, thanks for getting this done! LGTM, % questions/nits.
d980d68 to
7d57297
Compare
|
Closing due to 2 months of inactivity. Happy to talk about or reopen this if there is renewed interest. |
Ticket: https://viam.atlassian.net/browse/RSDK-2758
This provides a base
ViamExceptionclass and a few derived classes. The purpose of these exceptions are threefold:DuplicateResourceExceptionmight be handled differently than aPermissionDeniedException)This PR also creates
ViamErrorCodes which are 1 to 1 compatible with the exceptions and can be used interchangeably (though conversion will lose the message inside the exception).While working on this, I experimented with three main design options:
1)
I really liked this approach because it let me write very clean constructor calls. However this produced awful error messages (SFINAE was overkill for concat_varargs), and it required almost everything to live in the header files.
I really liked this approach because it gave very nice error messages; however, I am hesitant to suggest that we use macros. (we might also need to do some macro magic so that the full path of
__FILE__doesn't end up in the binary)The simple
Ultimately, I landed on number 3 because number 1 didn't end up providing as many benefits as I wanted and we can do number 2 later if we want to give more detailed error messages.
Important Notes: