Skip to content

Commit

Permalink
Box Octocrab error as it is too large (#1543)
Browse files Browse the repository at this point in the history
  • Loading branch information
mre authored Oct 26, 2024
1 parent 998ef6c commit 87d5b56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lychee-lib/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ impl ClientBuilder {
Octocrab::builder()
.personal_token(token.to_string())
.build()
// this is essentially the same reqwest::ClientBuilder::build error
// this is essentially the same `reqwest::ClientBuilder::build` error
// see https://docs.rs/octocrab/0.18.1/src/octocrab/lib.rs.html#360-364
.map_err(ErrorKind::BuildGithubClient)?,
.map_err(|e: octocrab::Error| ErrorKind::BuildGithubClient(Box::new(e)))?,
),
_ => None,
};
Expand Down Expand Up @@ -638,7 +638,7 @@ impl Client {
};
let repo = match client.repos(&uri.owner, &uri.repo).get().await {
Ok(repo) => repo,
Err(e) => return ErrorKind::GithubRequest(e).into(),
Err(e) => return ErrorKind::GithubRequest(Box::new(e)).into(),
};
if let Some(true) = repo.private {
// The private repo exists. Assume a given endpoint exists as well
Expand Down
15 changes: 9 additions & 6 deletions lychee-lib/src/types/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub enum ErrorKind {

/// Network error while using GitHub API
#[error("Network error (GitHub client)")]
GithubRequest(#[from] octocrab::Error),
GithubRequest(#[from] Box<octocrab::Error>),

/// Error while executing a future on the Tokio runtime
#[error("Task failed to execute to completion")]
Expand All @@ -46,7 +46,7 @@ pub enum ErrorKind {

/// The GitHub client required for making requests cannot be created
#[error("Error creating GitHub client")]
BuildGithubClient(#[source] octocrab::Error),
BuildGithubClient(#[source] Box<octocrab::Error>),

/// Invalid GitHub URL
#[error("GitHub URL is invalid: {0}")]
Expand Down Expand Up @@ -168,10 +168,13 @@ impl ErrorKind {
Some(utils::reqwest::trim_error_output(e))
}
}
ErrorKind::GithubRequest(e) => match e {
octocrab::Error::GitHub { source, .. } => Some(source.message.to_string()),
_ => None,
},
ErrorKind::GithubRequest(e) => {
if let octocrab::Error::GitHub { source, .. } = &**e {
Some(source.message.clone())
} else {
None
}
}
_ => self.source().map(ToString::to_string),
}
}
Expand Down

0 comments on commit 87d5b56

Please sign in to comment.