fix: add error context

This commit is contained in:
Yujia Qiao 2021-12-19 14:17:16 +08:00
parent b8e824849a
commit 1d5ad9c185
No known key found for this signature in database
GPG Key ID: DC129173B148701B
1 changed files with 5 additions and 2 deletions

View File

@ -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()?;