diff --git a/Cargo.lock b/Cargo.lock index 3e4326383..f9207df96 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1132,7 +1132,7 @@ dependencies = [ [[package]] name = "edgedb-derive" version = "0.5.1" -source = "git+https://github.com/edgedb/edgedb-rust/#a1094916fe28d090156c006722ca660cc29e06ad" +source = "git+https://github.com/edgedb/edgedb-rust/#3c3e8d33f7bb441059eefcc1f7f3fa6c5f0dc36d" dependencies = [ "proc-macro2", "quote", @@ -1143,7 +1143,7 @@ dependencies = [ [[package]] name = "edgedb-errors" version = "0.4.1" -source = "git+https://github.com/edgedb/edgedb-rust/#a1094916fe28d090156c006722ca660cc29e06ad" +source = "git+https://github.com/edgedb/edgedb-rust/#3c3e8d33f7bb441059eefcc1f7f3fa6c5f0dc36d" dependencies = [ "bytes", ] @@ -1151,7 +1151,7 @@ dependencies = [ [[package]] name = "edgedb-protocol" version = "0.6.0" -source = "git+https://github.com/edgedb/edgedb-rust/#a1094916fe28d090156c006722ca660cc29e06ad" +source = "git+https://github.com/edgedb/edgedb-rust/#3c3e8d33f7bb441059eefcc1f7f3fa6c5f0dc36d" dependencies = [ "bigdecimal", "bitflags 2.4.0", @@ -1167,7 +1167,7 @@ dependencies = [ [[package]] name = "edgedb-tokio" version = "0.5.0" -source = "git+https://github.com/edgedb/edgedb-rust/#a1094916fe28d090156c006722ca660cc29e06ad" +source = "git+https://github.com/edgedb/edgedb-rust/#3c3e8d33f7bb441059eefcc1f7f3fa6c5f0dc36d" dependencies = [ "anyhow", "arc-swap", diff --git a/src/connect.rs b/src/connect.rs index 537148406..84f62369d 100644 --- a/src/connect.rs +++ b/src/connect.rs @@ -8,7 +8,7 @@ use bytes::Bytes; use tokio::time::sleep; use tokio_stream::Stream; -use edgedb_errors::{Error, ErrorKind, ResultExt}; +use edgedb_errors::{Error, ErrorKind, ResultExt, AuthenticationError}; use edgedb_errors::{NoDataError, ProtocolEncodingError, ClientError}; use edgedb_protocol::QueryResult; use edgedb_protocol::client_message::{State, CompilationOptions}; @@ -176,7 +176,12 @@ impl Connector { _ => format!("EdgeDB instance at {}", cfg.display_addr()) }; - format!("Connecting to {}...", desc) + let wait = cfg.wait_until_available(); + let wait_msg = match wait.as_secs() { + seconds if seconds < 1 => format!("{}ms", wait.as_millis()), + seconds => format!("{seconds}s") + }; + format!("Connecting to {desc} (will try up to {wait_msg})...\n") } async fn print_warning(&self, cfg: &Config, interactive: bool) @@ -198,8 +203,20 @@ impl Connector { impl Connection { pub async fn connect(cfg: &Config) -> Result { + let connection = match raw::Connection::connect(&cfg).await { + Ok(conn) => conn, + Err(err) => { + if err.is::() { + eprintln!("Failed to authenticate.\ + \nHint: Use `edgedb info` to find and check the config for this instance"); + return Err(err) + } else { + return Err(err) + } + } + }; Ok(Connection { - inner: raw::Connection::connect(&cfg).await?, + inner: connection, state: State::empty(), server_version: None, config: cfg.clone(), diff --git a/src/options.rs b/src/options.rs index ef750b6a1..119f8a4f8 100644 --- a/src/options.rs +++ b/src/options.rs @@ -647,7 +647,10 @@ impl Options { } ); + let extra_help = "Hint: Setting RUST_LOG to `info`, `debug`, or `trace` can provide extra debugging info when encountering an issue.\n"; + let app = clap::Command::new("edgedb") + .after_help(extra_help) .term_width(term_width()) .args(deglobalized);