Hi there!
I'm trying to use a library to use TMDB's API: https://crates.io/crates/tmdb-api but I don't see how to get their Errors to play nice with anyhow:
use anyhow::anyhow;
use tmdb_api::{client::reqwest::ReqwestExecutor, prelude::Command};
async fn foo() -> anyhow::Result<()> {
_ = tmdb_api::tvshow::search::TVShowSearch::new("Gravity Falls".to_owned())
.execute(&tmdb_api::Client::<ReqwestExecutor>::new(
"api_key".to_owned(),
))
.await
.map_err(|e| anyhow!(e).context("Could not call TMDB API"));
Ok(())
}
fn main() {
println!("Hello, world!");
}
The anyhow!(e) call seems to want the e (i.e. tmdb_api::error::Error) to implement Sync, and I understand (a) this is because anyhow requires it and (b) anyhow requires it because it's required for async code. When I look at the definition for tmdb_api::error::Error, I see that there's some Boxed errors that aren't bound to implement Sync — is that the problem here?
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("couldn't execute request")]
Request {
#[source]
source: Box<dyn std::error::Error + Send>,
},
#[error("couldn't read response")]
Response {
#[source]
source: Box<dyn std::error::Error + Send>,
},
#[error(transparent)]
Validation(ServerValidationBodyError),
#[error("internal server error with code {code}")]
Server {
code: u16,
#[source]
content: ServerOtherBodyError,
},
}
Any way to make this work without introducing a ton of boilerplate on my part?
Thanks a lot 