I'm trying to follow Can I try/catch a warning? and treat all warnings as exceptions. I can get the error details in the custom error handler but the ErrorException I get in my catch block is always empty.
private function SetCustomExceptionHandler() {
set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) {
log_message('error', '$errno ' . $errno);
log_message('error', '$errstr ' . $errstr);
log_message('error', '$errfile ' . $errfile);
log_message('error', '$errline ' . $errline);
log_message('error', '$errcontext ' . json_encode($errcontext));
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});
}
$this->SetCustomExceptionHandler();
try {
//LDAP query that returns: ldap_search(): Partial search results returned: Sizelimit exceeded
}
catch (ErrorException $e) {
log_message('error', json_encode($e));
}