Skip to content

Commit

Permalink
remove unwrap and fix snafus
Browse files Browse the repository at this point in the history
  • Loading branch information
NickLarsenNZ committed Dec 18, 2023
1 parent c26bb0c commit 59f1060
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rust/user-info-fetcher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ enum StartupError {
#[snafu(display("failed to construct http client"))]
ConstructHttpClient { source: reqwest::Error },

#[snafu(display("failed to open ca certificate"))]
OpenCaCert { source: std::io::Error },

#[snafu(display("failed to read ca certificate"))]
ReadCaCert { source: std::io::Error },

Expand Down Expand Up @@ -132,10 +135,10 @@ async fn main() -> Result<(), StartupError> {
let mut buf = Vec::new();
File::open(tls_ca_cert_mount_path)
.await
.context(ReadCaCertSnafu)?
.context(OpenCaCertSnafu)?
.read_to_end(&mut buf)
.await
.unwrap();
.context(ReadCaCertSnafu)?;
let ca_cert = reqwest::Certificate::from_pem(&buf).context(ParseCaCertSnafu)?;

client_builder = client_builder
Expand Down

0 comments on commit 59f1060

Please sign in to comment.