Skip to content

Commit

Permalink
refactor: restore github error surfacing
Browse files Browse the repository at this point in the history
  • Loading branch information
colemickens committed Apr 17, 2024
1 parent c7c173f commit 20b5fc1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ impl Error {
}
}

// TODO(colemickens/review): was this used? where?
// /// Output a Github Actions annotation command if desired.
// // Note: These may only be one line! Any further lines will not be printed!
// pub(crate) fn maybe_github_actions_annotation(&self) {
// if std::env::var("GITHUB_ACTIONS").is_ok() {
// match self {
// Error::Unauthorized(message) => {
// println!("::error title=Unauthorized::{message}")
// }
// Error::Conflict { .. } => println!("::error title=Conflict::{self}"),
// }
// }
// }
// Note: These may only be one line! Any further lines will not be printed!
pub(crate) fn maybe_github_actions_annotation(&self) {
if std::env::var("GITHUB_ACTIONS").is_ok() {
match self {
Error::Unauthorized(message) => {
println!("::error title=Unauthorized::{message}")
}
Error::Conflict { .. } => println!("::error title=Conflict::{self}"),
}
}
}
}
12 changes: 12 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ async fn main() -> Result<std::process::ExitCode> {
})
.install()?;

match execute().await {
Ok(exit) => Ok(exit),
Err(error) => {
if let Some(known_error) = error.downcast_ref::<Error>() {
known_error.maybe_github_actions_annotation()
}
Err(error)
}
}
}

async fn execute() -> Result<std::process::ExitCode> {
let mut cli = cli::FlakeHubPushCli::parse();
cli.instrumentation.setup()?;

Expand Down

0 comments on commit 20b5fc1

Please sign in to comment.