diff --git a/shards/core/runtime.hpp b/shards/core/runtime.hpp index 7c9e447bdb..3f39a3d5e8 100644 --- a/shards/core/runtime.hpp +++ b/shards/core/runtime.hpp @@ -160,20 +160,6 @@ struct SHContext { return out; } - SHStateSnapshot takeStateSnapshot() { - return SHStateSnapshot{ - state, - std::move(flowStorage), - std::move(errorMessage), - }; - } - - void restoreStateSnapshot(SHStateSnapshot &&snapshot) { - errorMessage = std::move(snapshot.errorMessage); - state = std::move(snapshot.state); - flowStorage = std::move(snapshot.flowStorage); - } - constexpr void rebaseFlow() { state = SHWireState::Rebase; } constexpr void continueFlow() { state = SHWireState::Continue; } diff --git a/shards/modules/debug/debug.cpp b/shards/modules/debug/debug.cpp index 142361f4c7..3abe40968b 100644 --- a/shards/modules/debug/debug.cpp +++ b/shards/modules/debug/debug.cpp @@ -88,6 +88,18 @@ struct DumpWireStack { } }; +struct LastError { + static SHTypesInfo inputTypes() { return shards::CoreInfo::AnyType; } + static SHTypesInfo outputTypes() { return shards::CoreInfo::AnyType; } + static SHOptionalString help() { return SHCCSTR("Outputs the last error"); } + + OwnedVar _lastError; + + SHVar &activate(SHContext *shContext, const SHVar &input) { + _lastError = Var(shContext->getErrorMessage()); + return _lastError; + } +}; } // namespace shards::Debug namespace shards { @@ -96,5 +108,6 @@ SHARDS_REGISTER_FN(debug) { REGISTER_SHARD("Debug.Noop", DebugNoop); REGISTER_SHARD("Debug.DumpEnv", DumpEnv); REGISTER_SHARD("Debug.WireStack", DumpWireStack); + REGISTER_SHARD("Debug.LastError", LastError); } } // namespace shards