-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add explicit exceptions during command calls / handling #210
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
# Conflicts: # lib/everest.cpp Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Handle cmd timeout with new cmd error mechanism Add HandlerException and CmdTimeout exceptions that modules can specifically handle Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
…tain an id Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
Signed-off-by: Kai-Uwe Hermann <kai-uwe.hermann@pionix.de>
@@ -34,6 +34,49 @@ using TelemetryEntry = std::variant<std::string, const char*, bool, int32_t, uin | |||
using TelemetryMap = std::map<std::string, TelemetryEntry>; | |||
using UnsubscribeToken = std::function<void()>; | |||
|
|||
enum class ErrorType { |
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.
ErrorType
might be a bit vague and could lead to confusions with the "error framework"
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.
Maybe call this CallCmdEvent
or CmdEvent
HandlerException, | ||
Timeout, | ||
Shutdown, | ||
Unknown |
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.
remove Unknown
@@ -34,6 +34,49 @@ using TelemetryEntry = std::variant<std::string, const char*, bool, int32_t, uin | |||
using TelemetryMap = std::map<std::string, TelemetryEntry>; | |||
using UnsubscribeToken = std::function<void()>; | |||
|
|||
enum class ErrorType { |
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.
Maybe call this CallCmdEvent
or CmdEvent
}; | ||
|
||
struct ErrorMessage { | ||
ErrorType type; |
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.
event
Unknown | ||
}; | ||
|
||
struct ErrorMessage { |
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.
CmdResultError
class CmdError : public Everest::EverestBaseRuntimeError { | ||
public: | ||
using EverestBaseRuntimeError::EverestBaseRuntimeError; | ||
}; | ||
|
||
class HandlerException : public CmdError { | ||
public: | ||
using CmdError::CmdError; | ||
}; | ||
|
||
class CmdTimeout : public CmdError { | ||
public: | ||
using CmdError::CmdError; | ||
}; | ||
|
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.
Maybe already define exceptions for the other CallCmdEvent
s
EVLOG_verbose << fmt::format("Exception during handling of: {}->{}({}): {}", | ||
this->config.printable_identifier(this->module_id, impl_id), cmd_name, | ||
fmt::join(arg_names, ","), e.what()); | ||
error = ErrorMessage{ErrorType::HandlerException, e.what()}; |
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.
re-throw after result has been sent to caller so the handler still crashes
TODO: add test-cases |
Allow exceptions thrown in cmd handlers to be propagated to the calling module
This allows the caller to handle certain error conditions more gracefully (and could be extended for shutdown handling during cmd callc in the future as well)
A module could handle these new exceptions in the following way:
HandlerExceptions
andCmdTimeout
inherit fromCmdError
so a caller could also just catch this.(naming still up for debate)