3 namespace Drupal\Core\EventSubscriber;
5 use Drupal\Core\Utility\Error;
6 use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
9 * Custom handling of errors when in a system-under-test.
11 class ExceptionTestSiteSubscriber extends HttpExceptionSubscriberBase {
16 protected static function getPriority() {
23 protected function getHandledFormats() {
28 * Checks for special handling of errors inside Simpletest.
30 * @todo The $headers array appears to not actually get used at all in the
31 * original code. It's quite possible that this entire method is now
32 * vestigial and can be removed.
34 * @param \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event
36 public function on500(GetResponseForExceptionEvent $event) {
37 $exception = $event->getException();
38 $error = Error::decodeException($exception);
42 // When running inside the testing framework, we relay the errors
43 // to the tested site by the way of HTTP headers.
44 if (DRUPAL_TEST_IN_CHILD_SITE && !headers_sent() && (!defined('SIMPLETEST_COLLECT_ERRORS') || SIMPLETEST_COLLECT_ERRORS)) {
45 // $number does not use drupal_static as it should not be reset
46 // as it uniquely identifies each PHP error.
52 'function' => $error['%function'],
53 'file' => $error['%file'],
54 'line' => $error['%line'],
57 $headers['X-Drupal-Assertion-' . $number] = rawurlencode(serialize($assertion));