Print url for bad json error (#409)

Split out from #382
This commit is contained in:
konsti
2023-11-13 12:41:20 +01:00
committed by GitHub
parent fa423b8751
commit 81c9cd0d4a
2 changed files with 4 additions and 7 deletions
+1 -1
View File
@@ -171,7 +171,7 @@ impl RegistryClient {
match self.simple_impl(&url).await {
Ok(text) => {
return serde_json::from_str(&text)
.map_err(move |e| Error::from_json_err(e, String::new()));
.map_err(move |e| Error::from_json_err(e, url));
}
Err(err) => {
if err.status() == Some(StatusCode::NOT_FOUND) {
+3 -6
View File
@@ -41,11 +41,8 @@ pub enum Error {
#[error(transparent)]
RequestMiddlewareError(#[from] reqwest_middleware::Error),
#[error("Received some unexpected JSON: {source}")]
BadJson {
source: serde_json::Error,
url: String,
},
#[error("Received some unexpected JSON from {url}")]
BadJson { source: serde_json::Error, url: Url },
#[error(transparent)]
AsyncHttpRangeReader(#[from] AsyncHttpRangeReaderError),
@@ -71,7 +68,7 @@ pub enum Error {
}
impl Error {
pub fn from_json_err(err: serde_json::Error, url: String) -> Self {
pub fn from_json_err(err: serde_json::Error, url: Url) -> Self {
Self::BadJson { source: err, url }
}
}