aboutsummaryrefslogtreecommitdiff
path: root/tools/lldb-mi/MICmdBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lldb-mi/MICmdBase.cpp')
-rw-r--r--tools/lldb-mi/MICmdBase.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/tools/lldb-mi/MICmdBase.cpp b/tools/lldb-mi/MICmdBase.cpp
index cd5bf27c73fe..613f005cf754 100644
--- a/tools/lldb-mi/MICmdBase.cpp
+++ b/tools/lldb-mi/MICmdBase.cpp
@@ -214,6 +214,64 @@ void CMICmdBase::SetError(const CMIUtilString &rErrMsg) {
//++
//------------------------------------------------------------------------------------
+// Details: Short cut function to check MI command's execute status and
+// set an error in case of failure.
+// Type: Method.
+// Args: error - (R) Error description object.
+// successHandler - (R) function describing actions to execute
+// in case of success state of passed SBError object.
+// errorHandler - (R) function describing actions to execute
+// in case of fail status of passed SBError object.
+// Return: bool.
+// Throws: None.
+//--
+bool CMICmdBase::HandleSBError(const lldb::SBError &error,
+ const std::function<bool()> &successHandler,
+ const std::function<void()> &errorHandler) {
+ if (error.Success())
+ return successHandler();
+
+ SetError(error.GetCString());
+ errorHandler();
+ return MIstatus::failure;
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Short cut function to check MI command's execute status and
+// call specified handler function for success case.
+// Type: Method.
+// Args: error - (R) Error description object.
+// successHandler - (R) function describing actions to execute
+// in case of success state of passed SBError object.
+// Return: bool.
+// Throws: None.
+//--
+bool CMICmdBase::HandleSBErrorWithSuccess(
+ const lldb::SBError &error,
+ const std::function<bool()> &successHandler) {
+ return HandleSBError(error, successHandler);
+}
+
+//++
+//------------------------------------------------------------------------------------
+// Details: Short cut function to check MI command's execute status and
+// call specified handler function for error case.
+// Type: Method.
+// Args: error - (R) Error description object.
+// errorHandler - (R) function describing actions to execute
+// in case of fail status of passed SBError object.
+// Return: bool.
+// Throws: None.
+//--
+bool CMICmdBase::HandleSBErrorWithFailure(
+ const lldb::SBError &error,
+ const std::function<void()> &errorHandler) {
+ return HandleSBError(error, [] { return MIstatus::success; }, errorHandler);
+}
+
+//++
+//------------------------------------------------------------------------------------
// Details: Ask a command to provide its unique identifier.
// Type: Method.
// Args: A unique identifier for this command class.