Improve error message on timed out MX query

Any error, not only NoRecordExceptions, resulted in a MX record not found
error message. The previous message is now only shown if there's really no
record. Otherwise a more generic message is shown now.

Fixes #43.
This commit is contained in:
Niklas Keller
2016-12-14 19:21:41 +01:00
parent 8944aee552
commit 040aebe993

View File

@@ -3,6 +3,7 @@
namespace Kelunik\AcmeClient\Commands;
use Amp\CoroutineResult;
use Amp\Dns\NoRecordException;
use Amp\Dns\Record;
use Amp\Dns\ResolutionException;
use InvalidArgumentException;
@@ -80,8 +81,10 @@ class Setup implements Command {
try {
yield \Amp\Dns\query($host, Record::MX);
} catch (ResolutionException $e) {
} catch (NoRecordException $e) {
throw new AcmeException("No MX record defined for '{$host}'");
} catch (ResolutionException $e) {
throw new AcmeException("Dns query for an MX record on '{$host}' failed for the following reason: " . $e->getMessage(), null, $e);
}
}