Better error handling for issue #168

This commit is contained in:
James Cole
2016-02-10 15:18:13 +01:00
parent 71253b23d5
commit 4d6e244100
3 changed files with 78 additions and 0 deletions

View File

@@ -6,6 +6,10 @@ use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Mail\Message;
use Log;
use Mail;
use Swift_TransportException;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
@@ -39,6 +43,34 @@ class Handler extends ExceptionHandler
{
if ($exception instanceof FireflyException) {
// log
Log::error($exception->getMessage());
// mail?
try {
$email = env('SITE_OWNER');
$args = [
'errorMessage' => $exception->getMessage(),
'stacktrace' => $exception->getTraceAsString(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'code' => $exception->getCode(),
];
Mail::send(
['emails.error-html', 'emails.error'], $args,
function (Message $message) use ($email) {
if ($email != 'mail@example.com') {
$message->to($email, $email)->subject('Caught an error in Firely III.');
}
}
);
} catch (Swift_TransportException $e) {
// could also not mail! :o
Log::error($e->getMessage());
}
return response()->view('errors.FireflyException', ['exception' => $exception], 500);
}