View source
<?php
namespace Drupal\markdown\Util;
use Drupal\Core\Utility\Error as CoreError;
class Error extends CoreError {
public static function suppress(callable $callback, array &$exceptions = [], $errorTypes = E_ERROR | E_RECOVERABLE_ERROR | E_USER_ERROR) {
set_error_handler(function ($severity, $message, $file, $line) {
throw new \ErrorException($message, 0, $severity, $file, $line);
}, $errorTypes);
$result = NULL;
try {
$result = $callback();
} catch (\Throwable $exception) {
$exceptions[] = $exception;
} catch (\Exception $exception) {
$exceptions[] = $exception;
}
restore_error_handler();
return $result;
}
}