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

Refactor to use own Error type in the library api #32

Merged
merged 2 commits into from
Dec 30, 2020

Conversation

passcod
Copy link
Contributor

@passcod passcod commented Dec 29, 2020

As it's a library crate, having Anyhow as its error type makes it harder to integrate with anything that's not using Anyhow itself (chiefly due to it not implementing std::error::Error).

This PR refactors the code to use several thiserror-derived Error types and completely eliminates anyhow from library code.

It leaves anyhow as the output error library in the sp and spp executables, though.

The only holdover is an error variant which wraps anyhow when it comes from termwiz, and I'm also working on refactoring that crate to expose its own error type: wez/wezterm#406

@passcod
Copy link
Contributor Author

passcod commented Dec 29, 2020

The build failure (tests) seems unrelated?

@markbt
Copy link
Owner

markbt commented Dec 29, 2020

Thanks!

I might tweak some of the error messages, but this looks like a good improvement.

@markbt
Copy link
Owner

markbt commented Dec 29, 2020

The test problems were in the lru-cache crate, which seems to be unmaintained now. I've switched to lru, which seems to work.

That's introduces some conflicts. Can you rebase onto master so I can merge?

Using anyhow in a library's public interface is not recommended mainly
as it makes it tough to integrate with other libraries or existing
applications which may not use anyhow themselves, chiefly due to
anyhow::Error not implementing std::error::Error itself.

This commit instead refactors the code to use several thiserror[1]-derived
Error types and completely eliminates anyhow from library code.

It is still used as the output error library in the sp and spp
executables, though.

[1]: https://docs.rs/thiserror
@passcod
Copy link
Contributor Author

passcod commented Dec 30, 2020

Rebased!

@markbt markbt merged commit db1a247 into markbt:master Dec 30, 2020
@markbt
Copy link
Owner

markbt commented Dec 30, 2020

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.

None yet

2 participants