Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
84.62% covered (warning)
84.62%
11 / 13
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
TwigExceptionHandler
84.62% covered (warning)
84.62%
11 / 13
0.00% covered (danger)
0.00%
0 / 1
4.06
0.00% covered (danger)
0.00%
0 / 1
 withHtml
84.62% covered (warning)
84.62%
11 / 13
0.00% covered (danger)
0.00%
0 / 1
4.06
1<?php
2
3namespace BO\Zmsstatistic\Helper;
4
5use Psr\Http\Message\RequestInterface;
6use Psr\Http\Message\ResponseInterface;
7
8class TwigExceptionHandler extends \BO\Slim\TwigExceptionHandler
9{
10    #[\Override]
11    public static function withHtml(
12        RequestInterface $request,
13        ResponseInterface $response,
14        \Throwable $exception,
15        int $status = 500
16    ): ResponseInterface {
17        if ($exception instanceof \Slim\Exception\HttpNotFoundException) {
18            \BO\Slim\Controller::prepareRequest($request);
19            return \BO\Slim\Render::withHtml($response, 'page/404.twig');
20        }
21        try {
22            $workstation = \App::http()->readGetResult('/workstation/')->getEntity();
23            if ($exception instanceof \BO\Zmsclient\Exception) {
24                $exception->templatedata = [
25                    'workstation' => $workstation,
26                ];
27            }
28        } catch (\Throwable $workstationexception) {
29            \App::$log->warning('Failed to fetch /workstation/ for extendedInfo', [
30                'exception' => $workstationexception,
31            ]);
32        }
33
34        return parent::withHtml($request, $response, $exception, $status);
35    }
36}