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
By calling Url::parse it returns a Result<Url, ParseError>, so we need to do a match.
match url_ {Ok(url) => {let response = Fetch::Url(url).send().await?;returnOk(response);}Err(_) => Err(CustomError::new("Failed to parse.".into(),404u16)),}
The above could be simplified if url::ParseError is exported along with url::Url.
let url_ = Url::parse(&path)?;
But the above will not compile, it says the trait From<url::parser::ParseError> is not implemented for CustomError, now this should end because even if I implemented From<ParseError> for CustomError, ParseError is not exported.
Is there an existing issue for this?
What version of
workers-rs
are you using?0.0.18
What version of
wrangler
are you using?3.5.1
Describe the bug
When using
Fetch::url
, we first need to have the Url ready before we can use it.By calling
Url::parse
it returns aResult<Url, ParseError>
, so we need to do amatch
.The above could be simplified if
url::ParseError
is exported along withurl::Url
.But the above will not compile, it says
the trait From<url::parser::ParseError> is not implemented for CustomError
, now this should end because even if I implementedFrom<ParseError> for CustomError
,ParseError
is not exported.We can fix this by exporting ParseError in:
https://github.com/cloudflare/workers-rs/blob/main/worker/src/lib.rs line 11
Now this works!
Solution:
Since
url::Url
is re-exported,url::ParseError
should be exported too.Steps To Reproduce
No response
The text was updated successfully, but these errors were encountered: