Codice PHP:
error_reporting(E_ALL);
set_error_handler("noticeHandler"E_NOTICE);
function 
noticeHandler($errno$errstr){
   throw new 
Exception($errstr);
}

try{
  ...
  
$im imagecreatefromjpeg(...);
  ...
}catch(
Exception $ex){
 echo 
$ex->getMessage();