Better error handling #10

Open
opened 2026-06-26 15:59:26 +00:00 by decentral1se · 1 comment
Owner

It would be nice if we could avoid the thing we're doing as it's a bit clunky:

if err != nil {
  irohErr := err.(*iroh.IrohError)
  panic(irohErr.Message())
}

And instead just expose the error types directly:

https://github.com/n0-computer/iroh-ffi/blob/87509053e1dbe1e561c4abb0cd08481441c0edcb/src/error.rs#L39-L57

Then people can errors.Is(...) (or whatever) directly to check without the casting. I don't actually see this exposed in the API via the docs: https://godocs.io/git.coopcloud.tech/decentral1se/iroh-go so there might need to be some automagic conversion done 🤔

It would be nice if we could avoid the thing we're doing as it's a bit clunky: ```go if err != nil { irohErr := err.(*iroh.IrohError) panic(irohErr.Message()) } ``` And instead just expose the error types directly: > https://github.com/n0-computer/iroh-ffi/blob/87509053e1dbe1e561c4abb0cd08481441c0edcb/src/error.rs#L39-L57 Then people can `errors.Is(...)` (or whatever) directly to check without the casting. I don't actually see this exposed in the API via the docs: https://godocs.io/git.coopcloud.tech/decentral1se/iroh-go so there might need to be some automagic conversion done 🤔
Collaborator

yeah i was thinking of this too! big fan of being able to use errors.Is if possible

yeah i was thinking of this too! big fan of being able to use errors.Is if possible
Sign in to join this conversation.
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: decentral1se/iroh-go#10