LemmyNet / activitypub-federation-rust

High-level Rust library for the Activitypub protocol
GNU Affero General Public License v3.0
431 stars 47 forks source link

fix: make "other" error actually transparent #51

Closed phiresky closed 1 year ago

phiresky commented 1 year ago

This PR fixes the Display trait for the "Other" error. Before, these errors would just output "Other errors which are not explicitly handled" for everything without any other context. with this change, they output the full anyhow content.

e.g.: "data did not match any variant of untagged enum PersonOrGroup"

or: "Request error: error sending request for url (http://localhost:5313/u/Lady_Albedo_96): connection error: Connection reset by peer (os error 104)"

The reason for this issue was some bad interaction between the "displaydoc" library and the "thiserror" library. I tried a few other things to fix it but nothing except removing DisplayDoc worked.

This PR also adds a few random "context" calls that I needed while debugging something. They aren't great but imo the more anyhow context is used the better.

Nutomic commented 1 year ago

You need to run cargo fmt. Would also be worth asking the displaydoc upstream about fixing transparent errors.

phiresky commented 1 year ago

I've run cargo fmt.

asking the displaydoc upstream

I think there is already a old open issue about this: https://github.com/yaahc/displaydoc/issues/15

Nutomic commented 1 year ago

Alright thanks!