Skip to content

Commit c8868da

Browse files
authored
feat: pass FailState value to WasmVmIntegration::error() (#450)
* pass FailState value to WasmVmIntegration::error() Signed-off-by: Rachel Green <[email protected]>
1 parent 44be7b1 commit c8868da

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

include/proxy-wasm/wasm_vm.h

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,25 @@ enum class AbiVersion { ProxyWasm_0_1_0, ProxyWasm_0_2_0, ProxyWasm_0_2_1, Unkno
143143

144144
class NullPlugin;
145145

146+
enum class FailState : int {
147+
Ok = 0,
148+
UnableToCreateVm = 1,
149+
UnableToCloneVm = 2,
150+
MissingFunction = 3,
151+
UnableToInitializeCode = 4,
152+
StartFailed = 5,
153+
ConfigureFailed = 6,
154+
RuntimeError = 7,
155+
};
156+
146157
// Integrator specific WasmVm operations.
147158
struct WasmVmIntegration {
148159
virtual ~WasmVmIntegration() {}
149160
virtual WasmVmIntegration *clone() = 0;
150161
virtual proxy_wasm::LogLevel getLogLevel() = 0;
151162
virtual void error(std::string_view message) = 0;
163+
// Allow integrations to handle specific FailStates differently.
164+
virtual void error(FailState fail_state, std::string_view message) { error(message); }
152165
virtual void trace(std::string_view message) = 0;
153166
// Get a NullVm implementation of a function.
154167
// @param function_name is the name of the function with the implementation specific prefix.
@@ -165,17 +178,6 @@ struct WasmVmIntegration {
165178
void *ptr_to_function_return) = 0;
166179
};
167180

168-
enum class FailState : int {
169-
Ok = 0,
170-
UnableToCreateVm = 1,
171-
UnableToCloneVm = 2,
172-
MissingFunction = 3,
173-
UnableToInitializeCode = 4,
174-
StartFailed = 5,
175-
ConfigureFailed = 6,
176-
RuntimeError = 7,
177-
};
178-
179181
// Wasm VM instance. Provides the low level WASM interface.
180182
class WasmVm {
181183
public:
@@ -308,14 +310,11 @@ class WasmVm {
308310
*/
309311
virtual bool usesWasmByteOrder() = 0;
310312

311-
/**
312-
* Warm the VM such as engine and runtime.
313-
*/
314-
virtual void warm() = 0;
313+
virtual void warm() {}
315314

316315
bool isFailed() { return failed_ != FailState::Ok; }
317316
void fail(FailState fail_state, std::string_view message) {
318-
integration()->error(message);
317+
integration()->error(fail_state, message);
319318
failed_ = fail_state;
320319
for (auto &callback : fail_callbacks_) {
321320
callback(fail_state);

0 commit comments

Comments
 (0)