Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/EventSubscriber/FinalExceptionSubscriber.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\Core\EventSubscriber; | 3 namespace Drupal\Core\EventSubscriber; |
4 | 4 |
5 use Drupal\Component\Utility\SafeMarkup; | 5 use Drupal\Component\Render\FormattableMarkup; |
6 use Drupal\Core\Config\ConfigFactoryInterface; | 6 use Drupal\Core\Config\ConfigFactoryInterface; |
7 use Drupal\Core\StringTranslation\StringTranslationTrait; | 7 use Drupal\Core\StringTranslation\StringTranslationTrait; |
8 use Drupal\Core\Utility\Error; | 8 use Drupal\Core\Utility\Error; |
9 use Symfony\Component\EventDispatcher\EventSubscriberInterface; | 9 use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
10 use Symfony\Component\HttpFoundation\Response; | 10 use Symfony\Component\HttpFoundation\Response; |
96 unset($error['backtrace']); | 96 unset($error['backtrace']); |
97 | 97 |
98 if (!$this->isErrorLevelVerbose()) { | 98 if (!$this->isErrorLevelVerbose()) { |
99 // Without verbose logging, use a simple message. | 99 // Without verbose logging, use a simple message. |
100 | 100 |
101 // We call SafeMarkup::format directly here, rather than use t() since | 101 // We use \Drupal\Component\Render\FormattableMarkup directly here, |
102 // we are in the middle of error handling, and we don't want t() to | 102 // rather than use t() since we are in the middle of error handling, and |
103 // cause further errors. | 103 // we don't want t() to cause further errors. |
104 $message = SafeMarkup::format('%type: @message in %function (line %line of %file).', $error); | 104 $message = new FormattableMarkup('%type: @message in %function (line %line of %file).', $error); |
105 } | 105 } |
106 else { | 106 else { |
107 // With verbose logging, we will also include a backtrace. | 107 // With verbose logging, we will also include a backtrace. |
108 | 108 |
109 $backtrace_exception = $exception; | 109 $backtrace_exception = $exception; |
117 // once more in the backtrace. | 117 // once more in the backtrace. |
118 array_shift($backtrace); | 118 array_shift($backtrace); |
119 | 119 |
120 // Generate a backtrace containing only scalar argument values. | 120 // Generate a backtrace containing only scalar argument values. |
121 $error['@backtrace'] = Error::formatBacktrace($backtrace); | 121 $error['@backtrace'] = Error::formatBacktrace($backtrace); |
122 $message = SafeMarkup::format('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error); | 122 $message = new FormattableMarkup('%type: @message in %function (line %line of %file). <pre class="backtrace">@backtrace</pre>', $error); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 $content = $this->t('The website encountered an unexpected error. Please try again later.'); | 126 $content = $this->t('The website encountered an unexpected error. Please try again later.'); |
127 $content .= $message ? '</br></br>' . $message : ''; | 127 $content .= $message ? '</br></br>' . $message : ''; |