Expanded error handling.

This commit is contained in:
James Cole 2016-02-11 08:11:26 +01:00
parent 4cd7976f63
commit d08fa37ccf
3 changed files with 36 additions and 8 deletions

View File

@ -2,6 +2,7 @@
declare(strict_types = 1); declare(strict_types = 1);
namespace FireflyIII\Exceptions; namespace FireflyIII\Exceptions;
use ErrorException;
use Exception; use Exception;
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
@ -41,7 +42,7 @@ class Handler extends ExceptionHandler
*/ */
public function render($request, Exception $exception) public function render($request, Exception $exception)
{ {
if ($exception instanceof FireflyException) { if ($exception instanceof FireflyException || $exception instanceof ErrorException) {
// log // log
Log::error($exception->getMessage()); Log::error($exception->getMessage());
@ -70,8 +71,9 @@ class Handler extends ExceptionHandler
// could also not mail! :o // could also not mail! :o
Log::error($e->getMessage()); Log::error($e->getMessage());
} }
$isDebug = env('APP_DEBUG', false);
return response()->view('errors.FireflyException', ['exception' => $exception], 500); return response()->view('errors.FireflyException', ['exception' => $exception, 'debug' => $isDebug], 500);
} }
return parent::render($request, $exception); return parent::render($request, $exception);

View File

@ -12,10 +12,25 @@
padding: 0; padding: 0;
} }
.error-page {
background: #d2d6de; .ff-error-page {
width: 1000px;
margin: 20px auto 0 auto;
} }
.error-box { .ff-error-page > .headline {
float: left;
font-size: 100px;
font-weight: 300;
}
.ff-error-page > .error-content {
margin-left: 190px;
display: block;
}
.ff-error-page > .error-content > h3 {
font-weight: 300;
font-size: 25px;
}
.ff-error-box {
width: 460px; width: 460px;
margin: 7% auto; margin: 7% auto;
} }

View File

@ -33,8 +33,8 @@
<meta name="theme-color" content="#ffffff"> <meta name="theme-color" content="#ffffff">
</head> </head>
<body class="error-page"> <body class="ff-error-page">
<div class="error-box"> <div class="ff-error-box">
<div class="login-logo"> <div class="login-logo">
<a href="{{ route('index') }}"><b>Firefly</b>III</a> <a href="{{ route('index') }}"><b>Firefly</b>III</a>
</div> </div>
@ -55,7 +55,18 @@
</p> </p>
</div> </div>
</div> </div>
</div> </div>
{% if debug %}
<div class="error-stack">
<h4>Error</h4>
<p>This error occured in file <span style="font-family: monospace;">{{ exception.getFile }}</span> on line {{ exception.getLine }} with
code {{ exception.getCode }}.</p>
<h4>Stack trace</h4>
<div style="font-family: monospace;font-size:11px;">
{{ exception.getTraceAsString|nl2br }}
</div>
</div>
{% endif %}
</body> </body>
</html> </html>