Completed
Push — master ( 49b3e7...2989e5 )
by Jared
02:02
created

src/ExceptionHandler.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * @author Jared King <[email protected]>
5
 *
6
 * @link http://jaredtking.com
7
 *
8
 * @copyright 2015 Jared King
9
 * @license MIT
10
 */
11
namespace Infuse;
12
13 View Code Duplication
class ExceptionHandler
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    use HasApp;
16
17
    /**
18
     * @param Request    $req
19
     * @param Response   $res
20
     * @param \Exception $e
21
     *
22
     * @return Response
23
     */
24
    public function __invoke($req, $res, \Exception $e)
25
    {
26
        $this->app['logger']->error('An uncaught exception occurred while handling a request.', ['exception' => $e]);
27
28
        if ($req->isHtml()) {
29
            $res->render(new View('exception', [
30
                'title' => 'Internal Server Error',
31
                'exception' => $e, ]));
32
        }
33
34
        return $res->setCode(500);
35
    }
36
}
37