title: Can I try/catch a warning?
body: <p>I need to catch some warnings being thrown from some php native functions and then handle them.</p>
  
  <p>Specifically:</p>
  
  <pre><code>array dns_get_record  ( string $hostname  [, int $type= DNS_ANY  [, array &amp;$authns  [, array &amp;$addtl  ]]] )
  </code></pre>
  
  <p>It throws a warning when the DNS query fails.</p>
  
  <p><code>try</code>/<code>catch</code> doesn't work because a warning is not an exception.</p>
  
  <p>I now have 2 options:</p>
  
  <ol>
  <li><p><code>set_error_handler</code> seems like overkill because I have to use it to filter every warning in the page (is this true?);</p></li>
  <li><p>Adjust error reporting/display so these warnings don't get echoed to screen, then check the return value; if it's <code>false</code>, no records is found for hostname.</p></li>
  </ol>
  
  <p>What's the best practice here?</p>