-
Notifications
You must be signed in to change notification settings - Fork 62
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
Catch exceptions thrown in handler functions, send status to client #210
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.
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?
foxglove_bridge_base/include/foxglove_bridge/websocket_server.hpp
Outdated
Show resolved
Hide resolved
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 |
class ServiceUnknownError : public ServiceError { | ||
using ServiceError::ServiceError; | ||
}; | ||
class ServiceUnavailableError : public ServiceError { | ||
using ServiceError::ServiceError; | ||
}; | ||
class ServiceSchemaError : public ServiceError { | ||
using ServiceError::ServiceError; | ||
}; |
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.
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?
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 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
a4591b6
to
16d34c0
Compare
Public-Facing Changes
None
Description
Fixes #148