Skip to content

Commit

Permalink
Return exit code 1 when connection test fails
Browse files Browse the repository at this point in the history
Signed-off-by: Krzysztof Piotrowski <[email protected]>
  • Loading branch information
Ruadhri17 committed Aug 23, 2023
1 parent ea68aac commit 6d231b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 2 additions & 10 deletions crates/core/tedge/src/cli/connect/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,8 @@ impl Command for ConnectCommand {
println!("Connection check to {} cloud is successful.\n", cloud);
Ok(())
}
Ok(DeviceStatus::Unknown) | Err(_) => {
println!(
"Connection check to {} cloud failed.\n",
self.cloud.as_str()
);
Ok(())
}
Ok(DeviceStatus::Unknown) => Err(ConnectError::UnknownDeviceStatus.into()),
Err(err) => Err(err.into()),
};
} else {
return Err((ConnectError::DeviceNotConnected {
Expand Down Expand Up @@ -283,7 +278,6 @@ fn check_device_status_c8y(tedge_config: &TEdgeConfig) -> Result<DeviceStatus, C
Ok(DeviceStatus::Unknown)
} else {
// The request has not even been sent
println!("\nMake sure mosquitto is running.");
Err(ConnectError::TimeoutElapsedError)
}
}
Expand Down Expand Up @@ -359,7 +353,6 @@ fn check_device_status_azure(tedge_config: &TEdgeConfig) -> Result<DeviceStatus,
Ok(DeviceStatus::Unknown)
} else {
// The request has not even been sent
println!("Make sure mosquitto is running.");
Err(ConnectError::TimeoutElapsedError)
}
}
Expand Down Expand Up @@ -426,7 +419,6 @@ fn check_device_status_aws(tedge_config: &TEdgeConfig) -> Result<DeviceStatus, C
Ok(DeviceStatus::Unknown)
} else {
// The request has not even been sent
println!("Make sure mosquitto is running.");
Err(ConnectError::TimeoutElapsedError)
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/core/tedge/src/cli/connect/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ pub enum ConnectError {
#[error("Device is not connected to {cloud} cloud")]
DeviceNotConnected { cloud: String },

#[error("Unknown device status")]
UnknownDeviceStatus,

#[error(
"The JWT token received from Cumulocity is invalid.\nToken: {token}\nReason: {reason}"
)]
Expand Down

0 comments on commit 6d231b8

Please sign in to comment.