• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mattiabasone / minepic / 4096419641

pending completion
4096419641

push

github

Mattia Basone
mockery

744 of 864 relevant lines covered (86.11%)

4.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.42
/app/Exceptions/Handler.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Minepic\Exceptions;
6

7
use Illuminate\Auth\Access\AuthorizationException;
8
use Illuminate\Database\Eloquent\ModelNotFoundException;
9
use Illuminate\Http\Response;
10
use Illuminate\Validation\ValidationException;
11
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
12
use Minepic\Misc\SplashMessage;
13
use Symfony\Component\HttpKernel\Exception\HttpException;
14
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
15

16
class Handler extends ExceptionHandler
17
{
18
    /**
19
     * A list of the exception types that should not be reported.
20
     *
21
     * @var array
22
     */
23
    protected $dontReport = [
24
        AuthorizationException::class,
25
        HttpException::class,
26
        ModelNotFoundException::class,
27
        ValidationException::class,
28
    ];
29

30
    /**
31
     * Report or log an exception.
32
     *
33
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
34
     *
35
     * @param \Throwable $e
36
     *
37
     * @throws \Exception
38
     */
39
    public function report(\Throwable $e)
40
    {
41
        parent::report($e);
1✔
42
    }
43

44
    /**
45
     * Render an exception into an HTTP response.
46
     *
47
     * @param \Illuminate\Http\Request $request
48
     * @param \Throwable               $e
49
     *
50
     * @throws \Throwable
51
     *
52
     * @return mixed
53
     */
54
    public function render($request, \Throwable $e)
55
    {
56
        if ($e instanceof NotFoundHttpException) {
1✔
57
            return response(
1✔
58
                view('public.template.header', [
1✔
59
                    'title' => 'Ooops 404! - Minepic',
1✔
60
                    'description' => 'Error content not found',
1✔
61
                    'keywords' => '404, error',
1✔
62
                    'randomMessage' => SplashMessage::get404(),
1✔
63
                ]).
1✔
64
                view('public.errors.404').
1✔
65
                view('public.template.footer'),
1✔
66
                Response::HTTP_NOT_FOUND
1✔
67
            );
1✔
68
        }
69

70
        if ($e instanceof NotFoundHttpJsonException) {
×
71
            return response(
×
72
                json_encode(['ok' => false, $e->getMessage()], JSON_THROW_ON_ERROR),
×
73
                Response::HTTP_NOT_FOUND
×
74
            );
×
75
        }
76

77
        return parent::render($request, $e);
×
78
    }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc