Skip to content

Commit

Permalink
Print url for bad json error (#409)
Browse files Browse the repository at this point in the history
Split out from #382
  • Loading branch information
konstin authored Nov 13, 2023
1 parent fa423b8 commit 81c9cd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/puffin-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 3 additions & 6 deletions crates/puffin-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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 }
}
}

0 comments on commit 81c9cd0

Please sign in to comment.