1
0
mirror of https://github.com/danog/dns.git synced 2025-01-22 13:31:12 +01:00

Fix issues #25 and #26

This commit is contained in:
Bob Weinand 2016-03-14 22:50:59 +01:00
parent 2ca9766dff
commit daf859ec40

View File

@ -212,8 +212,12 @@ function __doResolve($name, array $types, $options) {
}
}
if (empty($types)) {
yield new CoroutineResult($result);
return;
if (empty(array_filter($result))) {
throw new NoRecordException("No records returned for {$name} (cached result)");
} else {
yield new CoroutineResult($result);
return;
}
}
}
@ -254,6 +258,11 @@ function __doResolve($name, array $types, $options) {
}
} catch (\Amp\CombinatorException $e) { // if all promises in Amp\some fail
if (empty($result)) { // if we have no cached results
foreach ($e->getExceptions() as $ex) {
if ($ex instanceof NoRecordException) {
throw new NoRecordException("No records returned for {$name}", 0, $e);
}
}
throw new ResolutionException("All name resolution requests failed", 0, $e);
}
}