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

epub_builder::Error no longer available for use in next release. #30

Open
dieterplex opened this issue Sep 11, 2022 · 4 comments
Open

Comments

@dieterplex
Copy link

dieterplex commented Sep 11, 2022

Since 1e3af55, epub_builder::Error is no longer available for using in downstream project. Specifically mdbook-epub is using epub_builder::Error to define a transparent error variant of thiserror. Without that, it would need to introduce eyre as a dependency IIUC and have some changes to upgrade to next release.

Could you consider re-exporting eyre::Report as Error for compatibility? Or give guidance to migrate?

Edit: see also Eyre's doc

We recommend users do not re-export types from this library as part their own public API for libraries with external users.

@erikbrinkman
Copy link
Contributor

You can always pin eyre to the same release as it is here, but I understand that's not an ideal solution 🤷

@dluschan
Copy link
Contributor

@blandger
Copy link

blandger commented Oct 15, 2023

Agree with @dieterplex now eyre is leaking from epub-builder into another library (mdbook-epub). That was not an good solution, imho.

@vuhe
Copy link

vuhe commented Jun 17, 2024

Can error be converted to std::error::Error so that there is no need to leak the eyre, I use this to convert to anyhow:

use std::error::Error;

type EpubBuilderError = Arc<dyn Error + Send + Sync + 'static>;

pub trait IntoStdError<T> {
    fn into_std_error(self) -> Result<T, EpubBuilderError>;
}

impl<T> IntoStdError<T> for epub_builder::Result<T> {
    fn into_std_error(self) -> Result<T, EpubBuilderError> {
        match self {
            Ok(it) => Ok(it),
            Err(e) => {
                let err: Box<dyn Error + Send + Sync + 'static> = e.into();
                let err: Arc<dyn Error + Send + Sync + 'static> = Arc::from(err);
                Err(err)
            }
        }
    }
}

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

No branches or pull requests

5 participants