From 299518d9357ca81efa12f295f65086708f392531 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 26 Apr 2021 19:39:55 +0000 Subject: fix(tls): throw meaningful error when hostname is invalid (#10387) `InvalidDNSNameError` is thrown when a string is not a valid hostname, e.g. it contains invalid characters, or starts with a numeric digit. It does not involve a (failed) DNS lookup. --- core/error.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'core') diff --git a/core/error.rs b/core/error.rs index a269d637f..65e2e8da4 100644 --- a/core/error.rs +++ b/core/error.rs @@ -36,6 +36,10 @@ pub fn type_error(message: impl Into>) -> AnyError { custom_error("TypeError", message) } +pub fn invalid_hostname(hostname: &str) -> AnyError { + type_error(format!("Invalid hostname: '{}'", hostname)) +} + pub fn uri_error(message: impl Into>) -> AnyError { custom_error("URIError", message) } -- cgit v1.2.3