Handle error reading token file
This commit is contained in:
parent
888ea9758b
commit
9148f2b77d
1 changed files with 6 additions and 2 deletions
|
@ -103,11 +103,15 @@ async fn main() -> Result<()> {
|
||||||
let token = if let Some(token) = token {
|
let token = if let Some(token) = token {
|
||||||
Some(token)
|
Some(token)
|
||||||
} else if let Some(token_file) = token_file {
|
} else if let Some(token_file) = token_file {
|
||||||
if let Ok(mut file) = std::fs::File::open(token_file) {
|
if let Ok(mut file) = std::fs::File::open(token_file.clone()) {
|
||||||
let mut buf = String::new();
|
let mut buf = String::new();
|
||||||
file.read_to_string(&mut buf).ok();
|
file.read_to_string(&mut buf).ok();
|
||||||
Some(buf)
|
Some(buf)
|
||||||
} else {
|
} else {
|
||||||
|
println!(
|
||||||
|
"Error reading API token file '{}'",
|
||||||
|
token_file.as_path().display()
|
||||||
|
);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -130,7 +134,7 @@ async fn main() -> Result<()> {
|
||||||
.insecure(insecure)
|
.insecure(insecure)
|
||||||
.format(format)
|
.format(format)
|
||||||
.build();
|
.build();
|
||||||
ha.open_connection().await.unwrap();
|
ha.open_connection().await.unwrap_or(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue