Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5231: Add infrastructure to catch and dispatch command execution fai…
…lures to the messagebus, for UI listeners to handle them.
- Loading branch information
1 parent
5061e9f
commit 2a82983
Showing
6 changed files
with
140 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include <stdexcept> | ||
|
||
namespace cmd | ||
{ | ||
|
||
/** | ||
* Exception type thrown when an operation failed. | ||
* Any function executed by the CommandSystem can throw this type, | ||
* it will be caught by the CommandSystem and possibly end up | ||
* displayed in an error popup window. | ||
*/ | ||
class ExecutionFailure : | ||
public std::runtime_error | ||
{ | ||
public: | ||
ExecutionFailure(const std::string& msg) : | ||
std::runtime_error(msg) | ||
{} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include "imessagebus.h" | ||
#include "command/ExecutionFailure.h" | ||
|
||
namespace radiant | ||
{ | ||
|
||
/** | ||
* Message object sent through the bus when an internal command | ||
* failed to execute. A reference to the thrown exception object | ||
* is stored internally and shipped with it. | ||
*/ | ||
class CommandExecutionFailedMessage : | ||
public radiant::IMessage | ||
{ | ||
private: | ||
const cmd::ExecutionFailure& _exception; | ||
|
||
public: | ||
CommandExecutionFailedMessage(const cmd::ExecutionFailure& exception) : | ||
_exception(exception) | ||
{} | ||
|
||
std::string getMessage() const | ||
{ | ||
return _exception.what(); | ||
} | ||
|
||
const cmd::ExecutionFailure& getException() const | ||
{ | ||
return _exception; | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters