|
@@ -18,11 +18,13 @@ pub struct User {
|
|
|
}
|
|
|
|
|
|
impl GithubClient {
|
|
|
- async fn _send_req(&self, req: RequestBuilder) -> Result<(Response, String), reqwest::Error> {
|
|
|
+ async fn _send_req(&self, req: RequestBuilder) -> anyhow::Result<(Response, String)> {
|
|
|
const MAX_ATTEMPTS: usize = 2;
|
|
|
log::debug!("_send_req with {:?}", req);
|
|
|
- let req = req.build()?;
|
|
|
let req_dbg = format!("{:?}", req);
|
|
|
+ let req = req
|
|
|
+ .build()
|
|
|
+ .with_context(|| format!("building reqwest {}", req_dbg))?;
|
|
|
|
|
|
let mut resp = self.client.execute(req.try_clone().unwrap()).await?;
|
|
|
if let Some(sleep) = Self::needs_retry(&resp).await {
|
|
@@ -272,7 +274,7 @@ where
|
|
|
#[derive(Debug)]
|
|
|
pub enum AssignmentError {
|
|
|
InvalidAssignee,
|
|
|
- Http(reqwest::Error),
|
|
|
+ Http(anyhow::Error),
|
|
|
}
|
|
|
|
|
|
#[derive(Debug)]
|
|
@@ -516,9 +518,11 @@ impl Issue {
|
|
|
}
|
|
|
}
|
|
|
Err(e) => {
|
|
|
- if e.status() == Some(reqwest::StatusCode::NOT_FOUND) {
|
|
|
- log::debug!("set_assignee: assignee is invalid, returning");
|
|
|
- return Err(AssignmentError::InvalidAssignee);
|
|
|
+ if let Some(e) = e.downcast_ref::<reqwest::Error>() {
|
|
|
+ if e.status() == Some(reqwest::StatusCode::NOT_FOUND) {
|
|
|
+ log::debug!("set_assignee: assignee is invalid, returning");
|
|
|
+ return Err(AssignmentError::InvalidAssignee);
|
|
|
+ }
|
|
|
}
|
|
|
log::debug!("set_assignee: get {} failed, {:?}", check_url, e);
|
|
|
return Err(AssignmentError::Http(e));
|