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:
@@ -3,6 +3,7 @@
|
|||||||
namespace Kelunik\AcmeClient\Commands;
|
namespace Kelunik\AcmeClient\Commands;
|
||||||
|
|
||||||
use Amp\CoroutineResult;
|
use Amp\CoroutineResult;
|
||||||
|
use Amp\Dns\NoRecordException;
|
||||||
use Amp\Dns\Record;
|
use Amp\Dns\Record;
|
||||||
use Amp\Dns\ResolutionException;
|
use Amp\Dns\ResolutionException;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
@@ -80,8 +81,10 @@ class Setup implements Command {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
yield \Amp\Dns\query($host, Record::MX);
|
yield \Amp\Dns\query($host, Record::MX);
|
||||||
} catch (ResolutionException $e) {
|
} catch (NoRecordException $e) {
|
||||||
throw new AcmeException("No MX record defined for '{$host}'");
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user