mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Better error handling for issue #168
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user