PHP Try ... catch how to?

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/]

[/var/www/] Cloudflare\API\Adapter\ResponseException::fromRequestException()
[/var/www/] Cloudflare\API\Adapter\Guzzle->request()

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) {