Properly catch errors during URL building
This commit is contained in:
parent
3d73094192
commit
d10b164b61
1 changed files with 14 additions and 7 deletions
|
|
@ -60,14 +60,21 @@ async fn run() -> anyhow::Result<()> {
|
|||
"{}/{}",
|
||||
meta.issue.repository.owner, meta.issue.repository.name
|
||||
))
|
||||
.expect("TODO");
|
||||
.with_context(|| {
|
||||
format!("failed building repository URL from GITHUB_SERVER_URL: {server_url}")
|
||||
})?;
|
||||
|
||||
let repo_auth_url = token.as_ref().map(|token| {
|
||||
let repo_auth_url = token
|
||||
.as_ref()
|
||||
.map(|token| -> Result<_, ()> {
|
||||
let mut repo_auth_url = repo_url.clone();
|
||||
repo_auth_url.set_username("forgejo-actions").expect("TODO");
|
||||
repo_auth_url.set_password(Some(&token)).expect("TODO");
|
||||
repo_auth_url
|
||||
});
|
||||
repo_auth_url.set_username("forgejo-actions")?;
|
||||
repo_auth_url.set_password(Some(&token))?;
|
||||
Ok(repo_auth_url)
|
||||
})
|
||||
.transpose()
|
||||
.map_err(|_e| anyhow::anyhow!("Repo URL does not have correct format"))
|
||||
.context("Failed adding auth info to repo URL")?;
|
||||
|
||||
let auth = if let Some(token) = token.as_ref() {
|
||||
forgejo_api::Auth::Token(token)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue