Skip to content

Commit 207dd5f

Browse files
committed
Add an overloaded error function that takes the fail_state so the integration implementation can handle errors differently for speific fail_states.
Signed-off-by: Rachel Green <[email protected]>
1 parent 0750dae commit 207dd5f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

include/proxy-wasm/wasm_vm.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ struct WasmVmIntegration {
149149
virtual WasmVmIntegration *clone() = 0;
150150
virtual proxy_wasm::LogLevel getLogLevel() = 0;
151151
virtual void error(std::string_view message) = 0;
152+
// Allow integrations to handle specific FailStates differently.
153+
virtual void error(FailState fail_state, std::string_view message) { error(message); }
152154
virtual void trace(std::string_view message) = 0;
153155
// Get a NullVm implementation of a function.
154156
// @param function_name is the name of the function with the implementation specific prefix.
@@ -315,11 +317,7 @@ class WasmVm {
315317

316318
bool isFailed() { return failed_ != FailState::Ok; }
317319
void fail(FailState fail_state, std::string_view message) {
318-
if (fail_state == FailState::RuntimeError) {
319-
integration()->error(std::string(PluginCrashPrefix) + std::string(message));
320-
} else {
321-
integration()->error(message);
322-
}
320+
integration()->error(fail_state, message);
323321
failed_ = fail_state;
324322
for (auto &callback : fail_callbacks_) {
325323
callback(fail_state);
@@ -349,7 +347,6 @@ class WasmVm {
349347
std::vector<std::function<void(FailState)>> fail_callbacks_;
350348

351349
private:
352-
static constexpr std::string_view PluginCrashPrefix = "Plugin crash: ";
353350
bool restricted_callback_{false};
354351
std::unordered_set<std::string> allowed_hostcalls_{};
355352
};

0 commit comments

Comments
 (0)