Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make "other" error actually transparent #51

Merged
merged 2 commits into from
Jun 29, 2023

Conversation

phiresky
Copy link
Contributor

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
Copy link
Member

Nutomic commented Jun 26, 2023

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

@@ -166,7 +166,8 @@ async fn sign_and_send(
task.private_key.clone(),
task.http_signature_compat,
)
.await?;
.await
.context("signing request")?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of these context it seems much cleaner if you add new variants to the error enum.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes much sense to pass all errors as structured errors to the outside - e.g. in this case the private key is broken which is kinda something that has to be fixed manually anyways. But it's really useful to at least get a tiny bit of context for what happened, which is what these changes do, with just a tiny change instead of a large change

@phiresky
Copy link
Contributor Author

I've run cargo fmt.

asking the displaydoc upstream

I think there is already a old open issue about this: yaahc/displaydoc#15

@Nutomic Nutomic merged commit b64f4a8 into LemmyNet:main Jun 29, 2023
@Nutomic
Copy link
Member

Nutomic commented Jun 29, 2023

Alright thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants