1
0
mirror of https://github.com/danog/dns.git synced 2024-11-30 04:29:06 +01:00

Improve warning if config loading fails

This commit is contained in:
Niklas Keller 2021-02-02 20:38:19 +01:00
parent 299511d7e6
commit 659bad6bba
2 changed files with 12 additions and 3 deletions

1
.gitignore vendored
View File

@ -3,4 +3,5 @@ composer.lock
phpunit.xml
vendor
.php_cs.cache
.phpunit.result.cache
coverage

View File

@ -187,7 +187,11 @@ final class Rfc1035StubResolver implements Resolver
throw $reason;
}
if ($searchIndex < \count($searchList) - 1 && \in_array($reason->getCode(), [2, 3], true)) {
if ($searchIndex < \count($searchList) - 1 && \in_array(
$reason->getCode(),
[2, 3],
true
)) {
continue 2;
}
@ -246,15 +250,19 @@ final class Rfc1035StubResolver implements Resolver
} catch (ConfigException $e) {
$this->configStatus = self::CONFIG_FAILED;
$message = "Could not load the system's DNS configuration; "
. "falling back to synchronous, blocking resolver; "
. \get_class($e) . ": " . $e->getMessage();
try {
\trigger_error(
"Could not load the system's DNS configuration, using synchronous, blocking fallback",
$message,
\E_USER_WARNING
);
} catch (\Throwable $triggerException) {
\set_error_handler(null);
\trigger_error(
"Could not load the system's DNS configuration, using synchronous, blocking fallback",
$message,
\E_USER_WARNING
);
\restore_error_handler();