@@ -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
351349private:
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