Add source method for custom error type #5
Labels
No Label
bug
documentation
duplicate
enhancement
help wanted
invalid
maintenance
peach-lib
peach-network
peach-oled
peach-stats
peach-web
question
refactor
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: PeachCloud/go-sbotcli-rs#5
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We need to add
source()
to provide a way for library users to access the underlying error (essentially, thestderr
of thesbotcli
which was invoked).The Rust docs offer a clear example of how to implement this:
https://doc.rust-lang.org/std/error/trait.Error.html#method.source
Thinking about this a bit more with an example:
Here's the output when I call
sbotcli call whoami
without a runninggo-sbot
(it returns two errors):In our library as it currently exists, this would result in the following error being displayed to the library user:
My current thought is that the basic error message that gets returned to the library caller should read like this:
Error calling whoami: failed to open unix path \"/home/glyph/.ssb-go/socket\"
or perhaps
Error calling whoami: failed to connect to 127.0.0.1:8008|@ZPKL+7GG2D5rAwu74tr1CHZNr+ODxdCCA9zwFFIZXl4=.ed25519
Then the
err.source()
would return the fullstderr
from the failed call: