|
morph 0.1.0
Asynchronous bridge between GUI thread and business models
|
Thrown when an action executed and its mutation committed, but the framework could not finish reporting that success. More...
#include <registry.hpp>
Public Member Functions | |
| ActionRecordingError (std::string result, std::string cause) | |
| Constructs the error with a message of the form "action executed but was not recorded: <cause>". | |
| const std::string & | result () const noexcept |
| Returns the committed action's JSON-encoded result. | |
| const std::string & | cause () const noexcept |
| Returns the underlying failure's message, without this type's prefix. | |
Thrown when an action executed and its mutation committed, but the framework could not finish reporting that success.
Raised by the two sites that actually run Model::execute — the server dispatch path (morph::model::detail::ActionDispatcher::registerAction's runner) and the in-process path (Bridge::executeVia's localOp, bridge.hpp) — for anything that fails after Model::execute returned: serialising the result (ActionTraits<Action>::resultToJson, which throws detail::ParseError) and appending the journal entry (a journal::IActionLog whose append could not reach its backend, which action_log.hpp requires it to signal by throwing).
It exists because those failures are not execution failures and must not be reported as one. An action whose journal append throws has already changed the model; telling the caller the action was rejected invites a retry of a write that landed, and recording journal::Outcome::Failed for it puts a permanent lie in the audit trail, attributed to the action rather than to the infrastructure that failed. So a post-execution failure is a distinct type carrying a distinct message: the action ran, the reporting did not.
No journal entry is written when the throw came from resultToJson. A Succeeded entry carries the result by definition (see docs/spec/journal/journal.md, LogEntry::result), and there is none to carry; the caller is told instead, which is the only channel left.
Deriving from std::runtime_error keeps existing catch (const std::exception&) handling working — RemoteServer::dispatchExecute's strand catch still turns this into an err reply, and LocalBackend's still rejects the Completion — while a caller that wants to tell a committed-but-unrecorded action from a rejected one can catch this type and read result().
Definition at line 385 of file registry.hpp.
|
inline |
Constructs the error with a message of the form "action executed but was not recorded: <cause>".
| result | JSON-encoded result of the committed action, or "" when serialising it is what failed. |
| cause | std::exception::what() from the failure that stopped the recording. |
Definition at line 393 of file registry.hpp.
|
inlinenodiscardnoexcept |
Returns the committed action's JSON-encoded result.
Definition at line 400 of file registry.hpp.
|
inlinenodiscardnoexcept |
Returns the underlying failure's message, without this type's prefix.
Definition at line 404 of file registry.hpp.