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

feat: add from_err() method to Report #403

Merged
merged 1 commit into from
Sep 7, 2024
Merged

feat: add from_err() method to Report #403

merged 1 commit into from
Sep 7, 2024

Conversation

johnbchron
Copy link
Contributor

There's no nice way to construct a bare Report from a regular Error type. You can construct Result<_, Report> from Result::<_, E: ...>, but not from an error by itself.

My workaround where e: impl Error + Send + Sync + 'static is to do Err::<(), _>(e).into_diagnostic().unwrap_err(), which obviously is ugly.

I added a Report::from_err() method that solves this problem in the same way as the IntoDiagnostic trait, by using its DiagnosticError type.

@zkat zkat merged commit 93d3bd1 into zkat:main Sep 7, 2024
15 checks passed
@zkat
Copy link
Owner

zkat commented Sep 7, 2024

hey this is nice. 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