At the moment if “addRecord” face record duplicate, on server it throws Internal Server Error like this:
Internal Server Error
Record already exists. [/var/www/domain.com/inc/vendor/Cloudflare/sdk/src/Adapter/ResponseException.php:38]
[/var/www/domain.com/inc/vendor/Cloudflare/sdk/src/Adapter/Guzzle.php:88] Cloudflare\API\Adapter\ResponseException::fromRequestException()
[/var/www/domain.com/inc/vendor/Cloudflare/sdk/src/Adapter/Guzzle.php:46] Cloudflare\API\Adapter\Guzzle->request()
Cloudflare\API\Endpoints\DNS->addRecord()
How to properly catch this error and display only this part?
Record already exists.
My try does not work – the same ISE is shown:
try {
$this->dns->addRecord($this->f3->cloudflare['zone_id'], $type, $name, $content);
} catch(exception $e) {
print_r($e->getMessage());
}