@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | RendererInterface $renderer, |
55 | 55 | ResponseFactoryInterface $responseFactory, |
56 | 56 | SnapshotterInterface $snapshots = null |
57 | - ) { |
|
57 | + ){ |
|
58 | 58 | $this->suppressErrors = $suppressErrors; |
59 | 59 | $this->renderer = $renderer; |
60 | 60 | $this->responseFactory = $responseFactory; |
@@ -68,22 +68,22 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function process(Request $request, Handler $handler): Response |
70 | 70 | { |
71 | - try { |
|
71 | + try{ |
|
72 | 72 | return $handler->handle($request); |
73 | - } catch (ClientException | RouterException $e) { |
|
74 | - if ($e instanceof ClientException) { |
|
73 | + }catch (ClientException | RouterException $e){ |
|
74 | + if ($e instanceof ClientException){ |
|
75 | 75 | $code = $e->getCode(); |
76 | - } else { |
|
76 | + }else{ |
|
77 | 77 | $code = 404; |
78 | 78 | } |
79 | - } catch (\Throwable $e) { |
|
80 | - if ($this->snapshots !== null) { |
|
79 | + }catch (\Throwable $e){ |
|
80 | + if ($this->snapshots !== null){ |
|
81 | 81 | $this->snapshots->register($e); |
82 | 82 | } |
83 | 83 | |
84 | 84 | $code = 500; |
85 | 85 | |
86 | - if (!$this->suppressErrors) { |
|
86 | + if (!$this->suppressErrors){ |
|
87 | 87 | return $this->renderException($request, $e); |
88 | 88 | } |
89 | 89 | } |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | { |
105 | 105 | $response = $this->responseFactory->createResponse(500); |
106 | 106 | |
107 | - if ($request->getHeaderLine('Accept') == 'application/json') { |
|
107 | + if ($request->getHeaderLine('Accept') == 'application/json'){ |
|
108 | 108 | $response = $response->withHeader('Content-Type', 'application/json'); |
109 | 109 | $handler = new JsonHandler(); |
110 | 110 | $response->getBody()->write(json_encode( |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | true |
115 | 115 | ) |
116 | 116 | )); |
117 | - } else { |
|
117 | + }else{ |
|
118 | 118 | $handler = new HtmlHandler(); |
119 | 119 | $response->getBody()->write($handler->renderException($e, HtmlHandler::VERBOSITY_VERBOSE)); |
120 | 120 | } |
@@ -68,22 +68,32 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function process(Request $request, Handler $handler): Response |
70 | 70 | { |
71 | - try { |
|
71 | + try |
|
72 | + { |
|
72 | 73 | return $handler->handle($request); |
73 | - } catch (ClientException | RouterException $e) { |
|
74 | - if ($e instanceof ClientException) { |
|
74 | + } |
|
75 | + catch (ClientException | RouterException $e) |
|
76 | + { |
|
77 | + if ($e instanceof ClientException) |
|
78 | + { |
|
75 | 79 | $code = $e->getCode(); |
76 | - } else { |
|
80 | + } |
|
81 | + else |
|
82 | + { |
|
77 | 83 | $code = 404; |
78 | 84 | } |
79 | - } catch (\Throwable $e) { |
|
80 | - if ($this->snapshots !== null) { |
|
85 | + } |
|
86 | + catch (\Throwable $e) |
|
87 | + { |
|
88 | + if ($this->snapshots !== null) |
|
89 | + { |
|
81 | 90 | $this->snapshots->register($e); |
82 | 91 | } |
83 | 92 | |
84 | 93 | $code = 500; |
85 | 94 | |
86 | - if (!$this->suppressErrors) { |
|
95 | + if (!$this->suppressErrors) |
|
96 | + { |
|
87 | 97 | return $this->renderException($request, $e); |
88 | 98 | } |
89 | 99 | } |
@@ -104,7 +114,8 @@ discard block |
||
104 | 114 | { |
105 | 115 | $response = $this->responseFactory->createResponse(500); |
106 | 116 | |
107 | - if ($request->getHeaderLine('Accept') == 'application/json') { |
|
117 | + if ($request->getHeaderLine('Accept') == 'application/json') |
|
118 | + { |
|
108 | 119 | $response = $response->withHeader('Content-Type', 'application/json'); |
109 | 120 | $handler = new JsonHandler(); |
110 | 121 | $response->getBody()->write(json_encode( |
@@ -114,7 +125,9 @@ discard block |
||
114 | 125 | true |
115 | 126 | ) |
116 | 127 | )); |
117 | - } else { |
|
128 | + } |
|
129 | + else |
|
130 | + { |
|
118 | 131 | $handler = new HtmlHandler(); |
119 | 132 | $response->getBody()->write($handler->renderException($e, HtmlHandler::VERBOSITY_VERBOSE)); |
120 | 133 | } |