Skip to content

Commit

Permalink
fix: improve error messages in tari applications (#2951)
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler committed Jun 1, 2021
2 parents db303e8 + 786f404 commit e04c884
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
13 changes: 8 additions & 5 deletions applications/tari_app_utilities/src/utilities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ pub const LOG_TARGET: &str = "tari::application";
pub enum ExitCodes {
#[error("There is an error in the wallet configuration: {0}")]
ConfigError(String),
#[error("The wallet exited because an unknown error occurred. Check the logs for details.")]
#[error("The application exited because an unknown error occurred. Check the logs for details.")]
UnknownError,
#[error("The wallet exited because an interface error occurred. Check the logs for details.")]
#[error("The application exited because an interface error occurred. Check the logs for details.")]
InterfaceError,
#[error("The wallet exited. {0}")]
#[error("The application exited. {0}")]
WalletError(String),
#[error("The wallet was not able to start the GRPC server. {0}")]
GrpcError(String),
#[error("The wallet did not accept the command input: {0}")]
#[error("The application did not accept the command input: {0}")]
InputError(String),
#[error("Invalid command: {0}")]
CommandError(String),
Expand All @@ -74,8 +74,10 @@ pub enum ExitCodes {
ConversionError(String),
#[error("Your password was incorrect.")]
IncorrectPassword,
#[error("Your wallet is encrypted but no password was provided.")]
#[error("Your application is encrypted but no password was provided.")]
NoPassword,
#[error("Tor connection is offline")]
TorOffline,
}

impl ExitCodes {
Expand All @@ -93,6 +95,7 @@ impl ExitCodes {
Self::NetworkError(_) => 110,
Self::ConversionError(_) => 111,
Self::IncorrectPassword | Self::NoPassword => 112,
Self::TorOffline => 113,
}
}
}
Expand Down
19 changes: 18 additions & 1 deletion applications/tari_base_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ use tari_app_utilities::{
utilities::{setup_runtime, ExitCodes},
};
use tari_common::{configuration::bootstrap::ApplicationType, ConfigBootstrap, GlobalConfig};
use tari_comms::peer_manager::PeerFeatures;
use tari_comms::{peer_manager::PeerFeatures, tor::HiddenServiceControllerError};
use tari_shutdown::{Shutdown, ShutdownSignal};
use tokio::{runtime, task, time};
use tonic::transport::Server;
Expand Down Expand Up @@ -198,6 +198,23 @@ async fn run_node(node_config: Arc<GlobalConfig>, bootstrap: ConfigBootstrap) ->
.await
.map_err(|err| {
error!(target: LOG_TARGET, "{}", err);
for boxed_error in err.chain() {
if let Some(HiddenServiceControllerError::TorControlPortOffline) =
boxed_error.downcast_ref::<HiddenServiceControllerError>()
{
println!("Unable to connect to the Tor control port.");
println!(
"Please check that you have the Tor proxy running and that access to the Tor control port is \
turned on.",
);
println!("If you are unsure of what to do, use the following command to start the Tor proxy:");
println!(
"tor --allow-missing-torrc --ignore-missing-torrc --clientonly 1 --socksport 9050 --controlport \
127.0.0.1:9051 --log \"notice stdout\" --clientuseipv6 1",
);
return ExitCodes::TorOffline;
}
}
ExitCodes::UnknownError
})?;

Expand Down

0 comments on commit e04c884

Please sign in to comment.