? 803760-error-display.patch
Index: imageapi_imagemagick.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imageapi/imageapi_imagemagick.module,v
retrieving revision 1.17.2.5
diff -u -p -r1.17.2.5 imageapi_imagemagick.module
--- imageapi_imagemagick.module	29 May 2009 17:48:32 -0000	1.17.2.5
+++ imageapi_imagemagick.module	19 May 2010 22:35:48 -0000
@@ -206,20 +206,25 @@ function _imageapi_imagemagick_convert_e
       $errors .= fgets($pipes[2]);
     }
 
+    fclose($pipes[0]);
+    fclose($pipes[1]);
+    fclose($pipes[2]);
+    $return_code = proc_close($h);
+
     // Display debugging information to authorized users.
     if (variable_get('imageapi_imagemagick_debugging', FALSE) && user_access('administer site configuration')) {
       drupal_set_message(t('ImageMagick command: @command', array('@command' => $convert_path .' '. $command_args)));
       drupal_set_message(t('ImageMagick output: @output', array('@output' => $output)));
     }
 
-    if ($errors) {
-      drupal_set_message(t('ImageMagick reported an error: %error', array('%error' => $errors)), 'error');
+    if (!$return_code) {
+      // If ImageMagick returned a non-zero code, trigger a PHP error that will
+      // be caught by Drupal's error handler, logged to the watchdog and
+      // eventually displayed to the user if configured to do so.
+      trigger_error(t('ImageMagick reported an error: %error', array('%error' => $errors)), E_USER_ERROR);
     }
 
-    fclose($pipes[0]);
-    fclose($pipes[1]);
-    fclose($pipes[2]);
-    return proc_close($h);
+    return $return_code;
   }
   return FALSE;
 }
