title: PHP cURL Couldn't resolve host
body: <p>I collect data from a website that, sometimes, seems to be not accessible (or, maybe it's just the DNS host that has sometimes some issues).
  The program written in PHP (launched with CLI) quits with the error:</p>
  
  <blockquote>
    <p>Couldn't resolve host 'abcdef.com'</p>
  </blockquote>
  
  <p>I would like to intercept this error, like with an exception, because the program must not quit.</p>
  
  <p>I tried a "try catch" but this doesn't work.</p>
  
  <p>I would like to avoid the use of an external daemon to restart the program...</p>
  
  <p>Thank you for your help.</p>
  
  <p>EDIT :
  The code used :</p>
  
  <pre><code>function goToPage($url) {
          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
          curl_setopt($ch, CURLOPT_COOKIEFILE, realpath("./cookies/cookie.txt"));
          $ret = curl_exec($ch);
          if ($ret === FALSE) {
              die(curl_error($ch));
          }
          curl_close($ch);
  
          $this-&gt;delay();
  
          return $ret;
  }
  </code></pre>