Passed
Push — master ( 94cefe...400934 )
by Anton
02:41
created
src/Http/Middleware/ErrorHandlerMiddleware.php 1 patch
Braces   +22 added lines, -9 removed lines patch added patch discarded remove patch
@@ -68,22 +68,32 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.