epub-builder
epub-builder copied to clipboard
Replace error-chain with other error handling library
hi!
error-chain is no longer maintained and difficult to use with modern error handling libraries.
Could you replace it with a more modern one, like anyhow?
Thanks! :)
To use anyhow with epub-builder I've used in src/errors.rs
use anyhow::anyhow;
pub trait EpubResultExt {
type Ok;
fn anyhow(self) -> anyhow::Result<Self::Ok>;
}
impl<T> EpubResultExt for Result<T, epub_builder::Error> {
type Ok = T;
fn anyhow(self) -> anyhow::Result<T> {
self.map_err(|e| anyhow!("epub error: {:?}", e))
}
}
In my program:
use errors:EpubResultExt
EpubBuilder::new(ZipLibrary::new().anyhow()?;
To be honest I've been quite away from Rust (and any programming) in a while so I've not followed recent developments, I'll try to look into it but if someone is willing to make a PR it's more likely to be quicker :)
No problem, left the comment here for others to find an way to work around the issue.