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

errors module is private #22

Closed
orhun opened this issue Jul 2, 2021 · 0 comments
Closed

errors module is private #22

orhun opened this issue Jul 2, 2021 · 0 comments

Comments

@orhun
Copy link
Collaborator

orhun commented Jul 2, 2021

Hi!

I'm trying to wrap APNGError in my application like this:

/* Custom error implementation */
#[derive(Debug, ThisError)]
pub enum AppError {
    // ...
    #[error("APNG error: `{0}`")]
    Apng(#[from] apng::errors::APNGError),
    // ...
}

But I get the following errors:

error[E0603]: module `errors` is private
  --> src/app.rs:51:21
   |
51 |     Apng(#[from] apng::errors::APNGError),
   |                        ^^^^^^ private module
   |
note: the module `errors` is defined here
  --> /home/orhun/.cargo/registry/src/github.com-1ecc6299db9ec823/apng-0.2.0/src/lib.rs:2:1
   |
2  | mod errors;
   | ^^^^^^^^^^^

error[E0599]: the method `as_dyn_error` exists for reference `&apng::errors::APNGError`, but its trait bounds were not satisfied
  --> src/app.rs:50:10
   |
50 |     #[error("APNG error: `{0}`")]
   |             ^^^^^^^^^^^^^^^^^^^ method cannot be called on `&apng::errors::APNGError` due to unsatisfied trait bounds
   | 
  ::: /home/orhun/.cargo/registry/src/github.com-1ecc6299db9ec823/apng-0.2.0/src/errors.rs:7:1
   |
7  | pub enum APNGError {
   | ------------------
   | |
   | doesn't satisfy `apng::errors::APNGError: AsDynError`
   | doesn't satisfy `apng::errors::APNGError: std::error::Error`
   |
   = note: the following trait bounds were not satisfied:
           `apng::errors::APNGError: std::error::Error`
           which is required by `apng::errors::APNGError: AsDynError`
           `&apng::errors::APNGError: std::error::Error`
           which is required by `&apng::errors::APNGError: AsDynError`

error: aborting due to 2 previous errors

First error is due to errors module being private. Applying the following diff solves the issue:

diff --git a/src/lib.rs b/src/lib.rs
index e0cb98b..ef3a84f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,5 @@
 mod apng;
-mod errors;
+pub mod errors;
 mod png;
 
 pub use crate::apng::*;

Second error is caused by the failure crate. It's fixed in #21

My question is: can we make errors module public? Or at least make APNGError public? I think it's important to expose these error types for use cases like mine.

What do you think? I'd like to provide a PR about this.

orhun added a commit to orhun/apng that referenced this issue Jul 10, 2021
poccariswet pushed a commit that referenced this issue Jul 13, 2021
@orhun orhun closed this as completed Jul 14, 2021
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

1 participant