Improve errors that confuse new users (#467)

* Make Get coinbase via wallet API error more self-help friendly. Also show the wallet API URL that failed to respond.
* spelling and rustfmt nit
* more informational output from `grin server stop`
* newcomer friendly error when wallet.seed isn't found
* grin wallet (info|outputs): better error message
This commit is contained in:
Simon B 2017-12-12 05:56:48 +01:00 committed by Ignotus Peverell
parent 8e6f54779e
commit 30a9c3db1e
5 changed files with 32 additions and 14 deletions

View file

@ -356,14 +356,17 @@ fn server_command(server_args: &ArgMatches, global_config: GlobalConfig) {
}
});
match daemonize.start() {
Ok(_) => info!(LOGGER, "Grin server succesfully started."),
Ok(_) => info!(LOGGER, "Grin server successfully started."),
Err(e) => error!(LOGGER, "Error starting: {}", e),
}
}
("stop", _) => println!("TODO, just 'kill $pid' for now."),
("stop", _) => println!("TODO. Just 'kill $pid' for now. Maybe /tmp/grin.pid is $pid"),
(cmd, _) => {
println!(":: {:?}", server_args);
panic!("Unknown server command '{}', use 'grin help server' for details", cmd);
panic!(
"Unknown server command '{}', use 'grin help server' for details",
cmd
);
}
}
}

View file

@ -35,7 +35,8 @@ pub fn create_coinbase(url: &str, block_fees: &BlockFees) -> Result<CbData, Erro
if let Err(_) = res {
error!(
LOGGER,
"Failed to get coinbase via wallet API (will retry)..."
"Failed to get coinbase from {}. Run grin wallet listen",
url
);
}
res
@ -73,7 +74,11 @@ fn single_send_partial_tx(url: &str, partial_tx: &PartialTx) -> Result<(), Error
if res.status() == hyper::StatusCode::Ok {
info!(LOGGER, "Transaction sent successfully");
} else {
error!(LOGGER, "Error sending transaction - status: {}", res.status());
error!(
LOGGER,
"Error sending transaction - status: {}",
res.status()
);
return Err(hyper::Error::Status);
}
Ok(())

View file

@ -78,6 +78,10 @@ pub fn show_info(config: &WalletConfig, keychain: &Keychain) {
});
if let Err(_) = result {
println!("WARNING - Showing local data only - Wallet was unable to contact a node to update and verify the info shown here.");
println!(
"\nWARNING: Wallet failed to verify data. \
The above is from local cache and possibly invalid! \
(is your `grin server` offline or broken?)"
);
}
}

View file

@ -93,6 +93,10 @@ pub fn show_outputs(config: &WalletConfig, keychain: &Keychain, show_spent:bool)
});
if let Err(_) = result {
println!("WARNING - Showing local data only - Wallet was unable to contact a node to update and verify the outputs shown here.");
println!(
"\nWARNING: Wallet failed to verify data. \
The above is from local cache and possibly invalid! \
(is your `grin server` offline or broken?)"
);
}
}

View file

@ -354,7 +354,10 @@ impl WalletSeed {
LOGGER,
"Run: \"grin wallet init\" to initialize a new wallet.",
);
panic!("wallet seed file does not yet exist (grin wallet init)");
panic!(format!(
"wallet seed file {} could not be opened (grin wallet init)",
seed_file_path
));
}
}
}
@ -522,7 +525,6 @@ impl WalletData {
max_outputs: usize,
default_strategy: bool,
) -> Vec<OutputData> {
// first find all eligible outputs based on number of confirmations
let mut eligible = self.outputs
.values()