Skip to content
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

Catch exceptions thrown in handler functions, send status to client #210

Merged
merged 5 commits into from
Apr 28, 2023

Conversation

achim-k
Copy link
Collaborator

@achim-k achim-k commented Apr 10, 2023

Public-Facing Changes

None

Description

  • Refactors the way handler functions are run in a separate thread. It's better to do that in a unified way in the server rather than doing that for ROS 1 & 2 differently as it was implemented in Run client handler functions in separate thread #165
  • Catch exeptions thrown in handler functions and send status message to client

Fixes #148

@achim-k achim-k requested a review from jtbandes April 10, 2023 18:57
Copy link
Member

@jtbandes jtbandes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good change overall. I have seen C++ codebases benefit greatly from a Status type, e.g. https://abseil.io/docs/cpp/guides/status, so that would be a nice improvement/cleanup to consider. I'm not sure if there is one already in the ROS package ecosystem?

@achim-k
Copy link
Collaborator Author

achim-k commented Apr 10, 2023

This seems like a good change overall. I have seen C++ codebases benefit greatly from a Status type, e.g. https://abseil.io/docs/cpp/guides/status, so that would be a nice improvement/cleanup to consider. I'm not sure if there is one already in the ROS package ecosystem?

I wonder if we should not simply throw exceptions if something went wrong. We already use exceptions in other places, so there is no good reason to not use them. This seems to be also what the C++ core guidelines recommend: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#e25-if-you-cant-throw-exceptions-simulate-raii-for-resource-management

@achim-k achim-k changed the title Make handler functions return status value Catch exceptions thrown in handler functions, send status to client Apr 11, 2023
@achim-k achim-k requested a review from jtbandes April 11, 2023 16:59
Comment on lines 67 to 75
class ServiceUnknownError : public ServiceError {
using ServiceError::ServiceError;
};
class ServiceUnavailableError : public ServiceError {
using ServiceError::ServiceError;
};
class ServiceSchemaError : public ServiceError {
using ServiceError::ServiceError;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we already have a detailed message as part of the error, I wonder if we really need a separate subclass for each type of error, or could you just use ServiceError for all of these?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the public API, so not sure what error granularity is best here. I guess I will remove all error types that are not explicitly caught in the server code

@achim-k achim-k force-pushed the achim/fg-1800_make_handler_functions_return_status branch from a4591b6 to 16d34c0 Compare April 27, 2023 15:32
@achim-k achim-k merged commit f208f96 into main Apr 28, 2023
6 checks passed
@achim-k achim-k deleted the achim/fg-1800_make_handler_functions_return_status branch April 28, 2023 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Handler functions do not give feedback if operation succeeded/failed
2 participants