diff options
author | Satya Rohith <me@satyarohith.com> | 2021-10-10 15:44:45 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 15:44:45 +0530 |
commit | 25771b3d9b36a7262d42809bfbb5497ed8057780 (patch) | |
tree | 47a41c2cb3b32b094ea9ca833c8bc28a3808ccb0 /ext/net/ops.rs | |
parent | 66804d26f3c12849c7fef9c7a27cb7beff5e3709 (diff) |
feat(ext/net): relevant errors for resolveDns (#12370)
Diffstat (limited to 'ext/net/ops.rs')
-rw-r--r-- | ext/net/ops.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/ext/net/ops.rs b/ext/net/ops.rs index 7019a9b1f..43a562e0f 100644 --- a/ext/net/ops.rs +++ b/ext/net/ops.rs @@ -35,6 +35,7 @@ use trust_dns_proto::rr::record_type::RecordType; use trust_dns_resolver::config::NameServerConfigGroup; use trust_dns_resolver::config::ResolverConfig; use trust_dns_resolver::config::ResolverOpts; +use trust_dns_resolver::error::ResolveErrorKind; use trust_dns_resolver::system_conf; use trust_dns_resolver::AsyncResolver; @@ -630,7 +631,19 @@ where let results = resolver .lookup(query, record_type, Default::default()) .await - .map_err(|e| generic_error(format!("{}", e)))? + .map_err(|e| { + let message = format!("{}", e); + match e.kind() { + ResolveErrorKind::NoRecordsFound { .. } => { + custom_error("NotFound", message) + } + ResolveErrorKind::Message("No connections available") => { + custom_error("NotConnected", message) + } + ResolveErrorKind::Timeout => custom_error("TimedOut", message), + _ => generic_error(message), + } + })? .iter() .filter_map(rdata_to_return_record(record_type)) .collect(); |