You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asyncfnfetch(url:String,sender:Sender<String>) -> anyhow::Result<()>{let body = surf::get(&url).recv_string().await?;
sender.send(body).await;Ok(())}
Error:
|
9 | let body = surf::get(&url).recv_string().await?;
| ^ doesn't have a size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `dyn std::error::Error + std::marker::Send + std::marker::Sync`
= note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
= note: required because of the requirements on the impl of `std::error::Error` for `std::boxed::Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>`
= note: required because of the requirements on the impl of `std::convert::From<std::boxed::Box<dyn std::error::Error + std::marker::Send + std::marker::Sync>>` for `anyhow::Error`
= note: required by `std::convert::From::from`
Workaround:
asyncfnfetch(url:String,sender:Sender<String>) -> anyhow::Result<()>{let body = surf::get(&url).recv_string().await.map_err(|e| anyhow!(e))?;
sender.send(body).await;Ok(())}
I think the proper solution is for the error type (Exception) to be a dedicated type that implements std::error::Error.
The text was updated successfully, but these errors were encountered:
Example:
Error:
Workaround:
I think the proper solution is for the error type (
Exception
) to be a dedicated type that implementsstd::error::Error
.The text was updated successfully, but these errors were encountered: