summaryrefslogtreecommitdiff
path: root/core/error.rs
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2021-04-26 19:39:55 +0000
committerBert Belder <bertbelder@gmail.com>2021-04-26 23:40:45 +0200
commit299518d9357ca81efa12f295f65086708f392531 (patch)
tree14817be22e60bf143f9d4108f5813dc985ec3ac5 /core/error.rs
parent87c055b371e6388f73c88ad26f56bca67f6691f4 (diff)
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.
Diffstat (limited to 'core/error.rs')
-rw-r--r--core/error.rs4
1 files changed, 4 insertions, 0 deletions
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<Cow<'static, str>>) -> 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<Cow<'static, str>>) -> AnyError {
custom_error("URIError", message)
}