@@ -367,9 +367,10 @@ function format_strawberryfield_cron() {
367367/**
368368 * Provides custom PHP error handling when processing ajax previews.
369369 *
370- * Converts trigger_error() to WARNING so that an exceptions can be thrown
371- * and caught by
370+ * Throws exceptions for E_USER_WARNING and E_USER_ERROR only
371+ * to be caught by
372372 * \Drupal\format_strawberryfield\MetadataDisplayForm::ajaxPreview().
373+ * All other errors are passed back to Drupal's error handler.
373374 *
374375 * @param int $error_level
375376 * The level of the error raised.
@@ -384,11 +385,19 @@ function format_strawberryfield_cron() {
384385 * error occurred.
385386 *
386387 * @throws \ErrorException
387- * Throw ErrorException for all errors passed from trigger_error() .
388+ * Throw ErrorException for E_USER_WARNING and E_USER_ERROR only .
388389 *
389390 * @see \Drupal\format_strawberryfield\MetadataDisplayForm::ajaxPreview()
390391 */
391392function _format_strawberryfield_metadata_preview_error_handler($error_level, $message, $filename = NULL, $line = NULL, $context = NULL) {
392- _drupal_error_handler(E_WARNING, $message, $filename, $line, $context);
393- throw new ErrorException($message, $error_level, 0, $filename, $line);
393+ switch($error_level)
394+ {
395+ case E_USER_WARNING:
396+ case E_USER_ERROR:
397+ _drupal_error_handler($error_level, $message, $filename, $line, $context);
398+ throw new ErrorException($message, $error_level, 0, $filename, $line);
399+ default:
400+ _drupal_error_handler($error_level, $message, $filename, $line, $context);
401+ break;
402+ }
394403}
0 commit comments