From 1d5ad9c185acb4de2908c5bb27121baf99e49d5f Mon Sep 17 00:00:00 2001 From: Yujia Qiao Date: Sun, 19 Dec 2021 14:17:16 +0800 Subject: [PATCH] fix: add error context --- src/transport/tls.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/transport/tls.rs b/src/transport/tls.rs index d6a246f..20b14ab 100644 --- a/src/transport/tls.rs +++ b/src/transport/tls.rs @@ -32,8 +32,11 @@ impl Transport for TlsTransport { let connector = match config.trusted_root.as_ref() { Some(path) => { - let s = fs::read_to_string(path).await?; - let cert = Certificate::from_pem(s.as_bytes())?; + let s = fs::read_to_string(path) + .await + .with_context(|| "Failed to read the `tls.trusted_root`")?; + let cert = Certificate::from_pem(s.as_bytes()) + .with_context(|| "Failed to read certificate from `tls.trusted_root`")?; let connector = native_tls::TlsConnector::builder() .add_root_certificate(cert) .build()?;