Subject: | $resolver->query fails with NOERROR if acount == 0 |
$ dig -t MX cel.leonerd.org.uk
; <<>> DiG 9.7.3 <<>> -t MX cel.leonerd.org.uk
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3317
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;cel.leonerd.org.uk. IN MX
;; AUTHORITY SECTION:
...
No answers, because this domain name does not have an MX record.
$ perl -MNet::DNS::Resolver -E'my $r = Net::DNS::Resolver->new; $r-
Show quoted text
>query("cel.leonerd.org.uk", "MX") or die $r->errorstring'
NOERROR at -e line 1.
This is not a very useful error result. It makes error reporting to the
caller trickier, because this doesn't directly describe the failure.
Perhaps the resolver's error string could be set to something indicating
no DNS error, but no data was found in the result? Perhaps something
similar to NODATA/NOADDRESS, as libc's res_query(3):
$ perl -MNet::LibResolv=:errors -E'say NO_DATA'
4
$ perl -MNet::LibResolv=res_query,:types,:classes,\$h_errno -
E'res_query("cel.leonerd.org.uk",NS_C_IN,NS_T_MX) or printf "%s (%d)\n",
$h_errno, $h_errno'
No address associated with name (4)
--
Paul Evans