forked from modstart/ModStartBlog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHandler.php
More file actions
58 lines (45 loc) · 1.46 KB
/
Copy pathHandler.php
File metadata and controls
58 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace App\Exceptions;
use Exception;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use ModStart\Core\Exception\BizException;
use ModStart\Core\Exception\ExceptionReportHandleTrait;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Handler extends ExceptionHandler
{
use ExceptionReportHandleTrait;
protected $dontReport = [
HttpException::class,
ModelNotFoundException::class,
BizException::class,
];
public function report(Exception $exception)
{
$this->errorReportCheck($exception);
parent::report($exception);
}
public function render($request, Exception $e)
{
if ($e instanceof ModelNotFoundException) {
$e = new NotFoundHttpException($e->getMessage(), $e);
}
$t = $this->getExceptionResponse($e);
if (null !== $t) {
return $t;
}
return parent::render($request, $e);
}
protected function convertExceptionToResponse(Exception $e)
{
$t = $this->getExceptionResponse($e);
if (null !== $t) {
return $t;
}
if (config('env.APP_DEBUG', true)) {
return parent::convertExceptionToResponse($e);
}
return response()->view('errors.500', ['exception' => $e], 500);
}
}