From 46e14461ebb0b1269412b4e3bd5139d2a7da3b12 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 11 Jul 2023 08:11:39 -0700 Subject: [PATCH] mux: improve domain name is invalid error message refs: #3907 --- mux/src/lib.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mux/src/lib.rs b/mux/src/lib.rs index 52f93546d..b0146e2d4 100644 --- a/mux/src/lib.rs +++ b/mux/src/lib.rs @@ -1099,9 +1099,20 @@ impl Mux { SpawnTabDomain::DomainId(domain_id) => self .get_domain(*domain_id) .ok_or_else(|| anyhow!("domain id {} is invalid", domain_id))?, - SpawnTabDomain::DomainName(name) => self - .get_domain_by_name(&name) - .ok_or_else(|| anyhow!("domain name {} is invalid", name))?, + SpawnTabDomain::DomainName(name) => { + self.get_domain_by_name(&name).ok_or_else(|| { + let names: Vec = self + .domains_by_name + .read() + .keys() + .map(|name| format!("\"{name}\"")) + .collect(); + anyhow!( + "domain name \"{name}\" is invalid. Possible names are {}.", + names.join(", ") + ) + })? + } }; Ok(domain) }