Fatal error with search record by an email

Fatal error with search record by an email

Hi guys
I need a function to check if the email is already added in Contacts module.
It works OK if the email exists.
It gives a fatal error if the email does not exists.
Here is the code:

    public function searchRecordsByEmail()
    {
        $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("Contacts"); // To get module instance
        $email="email@domain.com";//email id  to search for
        $page=1;//page number
        $perPage=200;//records per page
        $response = $moduleIns->searchRecordsByEmail($email, $page, $perPage); // To get module records//$searchWord word to be searched//$page to get the list of records from the respective pages. Default value for page is 1.//$perPage To get the list of records available per page. Default value for per page is 200.
        $records = $response->getData(); // To get response data
        try {
            foreach ($records as $record) {
                echo "\n\n";
                echo $record->getEntityId(); // To get record id

            }
        } catch (ZCRMException $ex) {
            echo $ex->getMessage(); // To get ZCRMException error message
            echo $ex->getExceptionCode(); // To get ZCRMException error code
            echo $ex->getFile(); // To get the file name that throws the Exception
        }
    }

And here is the error:
Fatal error: Uncaught zcrmsdk\crm\exception\ZCRMException Caused by:'No Content' in vendor/zohocrm/php-sdk/src/crm/api/response/BulkAPIResponse.php(61) #0 vendor/zohocrm/php-sdk/src/crm/api/response/CommonAPIResponse.php(76): zcrmsdk\crm\api\response\BulkAPIResponse->handleForFaultyResponses() #1 vendor/zohocrm/php-sdk/src/crm/api/response/CommonAPIResponse.php(67): zcrmsdk\crm\api\response\CommonAPIResponse->processResponse() #2 vendor/zohocrm/php-sdk/src/crm/api/response/BulkAPIResponse.php(47): zcrmsdk\crm\api\response\CommonAPIResponse->__construct('HTTP/1.1 204 \r\n...', 204) #3 vendor/zohocrm/php-sdk/src/crm/api/APIRequest.php(123): zcrmsdk\crm\api\response\BulkAPIResponse->__construct('HTTP/1.1 204 \r\n...', 204) #4 vendor/zohocrm/php-sdk in vendor/zohocrm/php-sdk/src/crm/api/response/BulkAPIResponse.php on line 61

Any idea why it is not catching the error here?

Thank you