Mcdostone / go-pdk-error-handling

0 stars 0 forks source link

error handling #1

Closed nilslice closed 2 weeks ago

nilslice commented 2 weeks ago

Hi @Mcdostone - sorry if this was already addressed, but this repo just came up in a recent search and I wanted to offer some help.

In the scenario where the return code is 0, but you've set the error in the PDK function, Rust SDK will convert that into a Rust Err variant of the Result returned. So when you call .unwrap(), this will always panic if an Err is encountered.

You would need to update your host code to check the Result returned from the plugin call and see if it is an Err and handle it directly.

Mcdostone commented 2 weeks ago

Hi,

this repo exists to describe a bug I found few months ago: https://github.com/extism/go-pdk/issues/33#event-13122159694 The issue is fixed.