Skip to content

Commit 16273fb

Browse files
author
zach
authored
fix: improve error handling (#24)
Updates `call` to raise an error when the plugin error is set and the plugin returns 0 Related to #23
1 parent 309b7b3 commit 16273fb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

extism/extism.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,10 @@ def cancel_handle(self):
507507
return CancelHandle(_lib.extism_plugin_cancel_handle(self.plugin))
508508

509509
def _check_error(self, rc):
510+
error = _lib.extism_plugin_error(self.plugin)
511+
if error != _ffi.NULL:
512+
raise Error(_ffi.string(error).decode())
510513
if rc != 0:
511-
error = _lib.extism_plugin_error(self.plugin)
512-
if error != _ffi.NULL:
513-
raise Error(_ffi.string(error).decode())
514514
raise Error(f"Error code: {rc}")
515515

516516
def function_exists(self, name: str) -> bool:

0 commit comments

Comments
 (0)