diff options
Diffstat (limited to 'phpBB/phpbb/event/kernel_exception_subscriber.php')
-rw-r--r-- | phpBB/phpbb/event/kernel_exception_subscriber.php | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/phpBB/phpbb/event/kernel_exception_subscriber.php b/phpBB/phpbb/event/kernel_exception_subscriber.php index 44e87507f9..1e536c1b8f 100644 --- a/phpBB/phpbb/event/kernel_exception_subscriber.php +++ b/phpBB/phpbb/event/kernel_exception_subscriber.php @@ -14,9 +14,9 @@ namespace phpbb\event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpFoundation\Response; class kernel_exception_subscriber implements EventSubscriberInterface @@ -57,9 +57,16 @@ class kernel_exception_subscriber implements EventSubscriberInterface $exception = $event->getException(); + $message = $exception->getMessage(); + + if ($exception instanceof \phpbb\exception\exception_interface) + { + $message = call_user_func_array(array($this->user, 'lang'), array_merge(array($message), $exception->get_parameters())); + } + $this->template->assign_vars(array( 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'), - 'MESSAGE_TEXT' => $exception->getMessage(), + 'MESSAGE_TEXT' => $message, )); $this->template->set_filenames(array( @@ -68,8 +75,14 @@ class kernel_exception_subscriber implements EventSubscriberInterface page_footer(true, false, false); - $status_code = $exception instanceof HttpException ? $exception->getStatusCode() : 500; - $response = new Response($this->template->assign_display('body'), $status_code); + $response = new Response($this->template->assign_display('body'), 500); + + if ($exception instanceof HttpExceptionInterface) + { + $response->setStatusCode($exception->getStatusCode()); + $response->headers->add($exception->getHeaders()); + } + $event->setResponse($response); } |