Skip to content

Commit

Permalink
Display the path in the open GCS credentials error (#4124)
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxins authored Apr 25, 2023
1 parent 8d166a1 commit b981921
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions object_store/src/gcp/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ use snafu::{ResultExt, Snafu};
use std::env;
use std::fs::File;
use std::io::BufReader;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::time::{Duration, Instant};
use tracing::info;

#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("Unable to open service account file: {}", source))]
OpenCredentials { source: std::io::Error },
#[snafu(display("Unable to open service account file from {}: {}", path.display(), source))]
OpenCredentials {
source: std::io::Error,
path: PathBuf,
},

#[snafu(display("Unable to decode service account file: {}", source))]
DecodeCredentials { source: serde_json::Error },
Expand Down Expand Up @@ -233,7 +236,9 @@ fn read_credentials_file<T>(
where
T: serde::de::DeserializeOwned,
{
let file = File::open(service_account_path).context(OpenCredentialsSnafu)?;
let file = File::open(&service_account_path).context(OpenCredentialsSnafu {
path: service_account_path.as_ref().to_owned(),
})?;
let reader = BufReader::new(file);
serde_json::from_reader(reader).context(DecodeCredentialsSnafu)
}
Expand Down

0 comments on commit b981921

Please sign in to comment.