Skip to content

Commit

Permalink
cli: improve error message for holod connection failures
Browse files Browse the repository at this point in the history
Provide a more user-friendly error message when holo-cli can't connect
to holod (usually due to holod not running).

Signed-off-by: Renato Westphal <[email protected]>
  • Loading branch information
rwestphal committed Sep 2, 2023
1 parent 7e2912e commit 5b2f0de
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions holo-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,14 @@ fn main() {

// Initialize YANG context and gRPC client.
let mut yang_ctx = yang::new_context();
let mut client =
GrpcClient::connect(grpc_addr).expect("Failed to connect to holod");
let mut client = match GrpcClient::connect(grpc_addr) {
Ok(client) => client,
Err(error) => {
eprintln!("Connection to holod failed : {}\n", error);
eprintln!("Please ensure that holod is currently running.");
std::process::exit(1);
}
};
client.load_modules(&mut yang_ctx);
YANG_CTX.set(Arc::new(yang_ctx)).unwrap();

Expand Down

0 comments on commit 5b2f0de

Please sign in to comment.