Skip to content

Commit fac843a

Browse files
improve output of errors
1 parent 57a8862 commit fac843a

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub fn get_args() -> Result<Args, Box<dyn std::error::Error>> {
164164
}
165165
match fs::read_to_string(&jwt_path) {
166166
Ok(jwt) => args.jwt = String::from(jwt.trim()),
167-
Err(error) => eprintln!("Failed to read jwt from {:?}: {:?}", &jwt_path, error),
167+
Err(error) => eprintln!("Failed to read jwt from {:?}: {}", &jwt_path, error.to_string()),
168168
}
169169
}
170170

src/auth.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,13 @@ pub async fn authenticate_service_account(context: &mut Context) -> Result<(), B
122122
);
123123
}
124124
}
125-
Err(error) => return Err(format!("Failed to authenticate: {:?}", error).into()),
125+
Err(error) => {
126+
if context.args.verbose {
127+
return Err(format!("Failed to authenticate: {:?}", error).into());
128+
}
129+
130+
return Err(format!("Failed to authenticate: {}", error.to_string()).into());
131+
}
126132
};
127133

128134
return Ok(());

src/query.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ pub async fn query(context: &mut Context, query_text: String) -> Result<(), Box<
192192
// on stdout, on purpose
193193
println!("{}", resp.text().await?);
194194
}
195-
Err(error) => eprintln!("Failed to send the request: {:?}", error),
195+
Err(error) => {
196+
if context.args.verbose {
197+
eprintln!("Failed to send the request: {:?}", error);
198+
} else {
199+
eprintln!("Failed to send the request: {}", error.to_string());
200+
}
201+
},
196202
};
197203

198204
if !context.args.concise {

0 commit comments

Comments
 (0)