title: Getting "PHP Warning: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known"
body: <p>With a php script like the below, I expected it'd throw an exception and try/catch block will catch it.</p>
  
  <pre><code>&lt;?php
  try {
      $dbh = new PDO('mysql:host=does-not-exist;dbname=test;port=3306', 'root', '');
      $dbh-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  } catch (PDOException $e) {
      echo $e-&gt;getMessage(), PHP_EOL;
  }
  </code></pre>
  
  <p>But I'm getting a warning error as well. Any workaround?</p>
  
  <pre><code>PHP Warning:  PDO::__construct(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /var/www/pdo.php on line 3
  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known
  </code></pre>