error_get_last() returns NULL after valid error in Drush I have the following command callback function defined in my .drush.inc file:

function drush_bv_ftp_products() {
  echo $aadfadf;
  var_dump(error_get_last());
}


Assume hook_drush_command() is properly implemented and has an alias of 'abc'.

When I run drush site.local abc I get NULL for output.  What I would expect to see is similar to:

Array
(
    [type] =&gt; 8
    [message] =&gt; Undefined variable: aadfadf
    [file] =&gt; ...
    [line] =&gt; ...
)


I'm running php 5.3.28 so error_get_last is there.  Any thoughts from the Drush masters out there as to what could be going wrong here?
Drush sets an error handler via set_error_handler('drush_error_handler');.  This interferes with the operation of error_get_last()`, as php resets the last error when the error handler is called; error_get_last() always returns NULL with an error handler, even if it is the first function called in the handler.

Since there is no way to disable the Drush error handler, this prevents the use of error_get_last() in Drush command files.  For a quick test, you could always temporarily comment out the call to set_error_handler in Drush.