Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Don't panic in auth flow (#49916)

Conrad Irwin04a2f059e28d
diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs
index 48041f2271d..45bf43d4e73 100644
--- a/crates/client/src/client.rs
+++ b/crates/client/src/client.rs
@@ -1369,9 +1369,9 @@ impl Client {
// zed server to encrypt the user's access token, so that it can'be intercepted by
// any other app running on the user's device.
let (public_key, private_key) =
- rpc::auth::keypair().expect("failed to generate keypair for auth");
+ rpc::auth::keypair().context("failed to generate keypair for auth")?;
let public_key_string = String::try_from(public_key)
- .expect("failed to serialize public key for auth");
+ .context("failed to serialize public key for auth")?;
if let Some((login, token)) =
IMPERSONATE_LOGIN.as_ref().zip(ADMIN_API_TOKEN.as_ref())
@@ -1386,8 +1386,8 @@ impl Client {
}
// Start an HTTP server to receive the redirect from Zed's sign-in page.
- let server =
- tiny_http::Server::http("127.0.0.1:0").expect("failed to find open port");
+ let server = tiny_http::Server::http("127.0.0.1:0")
+ .map_err(|e| anyhow!(e).context("failed to bind callback port"))?;
let port = server.server_addr().port();
// Open the Zed sign-in page in the user's browser, with query parameters that indicate