Skip to content

Commit

Permalink
fix: improve error handling (#24)
Browse files Browse the repository at this point in the history
Updates `call` to raise an error when the plugin error is set and the
plugin returns 0

Related to #23
  • Loading branch information
zshipko authored Jul 23, 2024
1 parent 309b7b3 commit 16273fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions extism/extism.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,10 +507,10 @@ def cancel_handle(self):
return CancelHandle(_lib.extism_plugin_cancel_handle(self.plugin))

def _check_error(self, rc):
error = _lib.extism_plugin_error(self.plugin)
if error != _ffi.NULL:
raise Error(_ffi.string(error).decode())
if rc != 0:
error = _lib.extism_plugin_error(self.plugin)
if error != _ffi.NULL:
raise Error(_ffi.string(error).decode())
raise Error(f"Error code: {rc}")

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

0 comments on commit 16273fb

Please sign in to comment.