Skip to content

Firefly III: a personal finances manager

Some changes to the error handler

James Cole43ff3e11ed6a
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 110ac12f83..b4ead350ef 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -12,7 +12,6 @@ use Log;
use Mail;
use Swift_TransportException;
use Symfony\Component\HttpKernel\Exception\HttpException;
-use Auth;
/**
* Class Handler
@@ -51,15 +50,17 @@ class Handler extends ExceptionHandler
// mail?
try {
$email = env('SITE_OWNER');
-
+ $user = $request->user();
$args = [
'errorMessage' => $exception->getMessage(),
'stacktrace' => $exception->getTraceAsString(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'code' => $exception->getCode(),
- 'loggedIn' => Auth::check(),
- 'user' => Auth::user(),
+ 'loggedIn' => !is_null($user),
+ 'user' => $user,
+ 'ip' => $request->ip(),
+
];
Mail::send(
diff --git a/resources/views/emails/error-html.twig b/resources/views/emails/error-html.twig
index 83d3b084ee..aeb6f6c040 100644
--- a/resources/views/emails/error-html.twig
+++ b/resources/views/emails/error-html.twig
@@ -12,11 +12,17 @@
This error occured in file <span style="font-family: monospace;">{{ file }}</span> on line {{ line }} with code {{ code }}.
</p>
-{% if loggedIn %}
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">
- The error was encountered by user #{{ user.id }}, <a href="mailto:{{ user.email }}">{{ user.email }}</a>.
+ {% if loggedIn %}
+ The error was encountered by user #{{ user.id }}, <a href="mailto:{{ user.email }}">{{ user.email }}</a>.
+ {% else %}
+ There was no user logged in for this error or no user was detected.
+ {% endif %}
+</p>
+
+<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">
+ The IP address related to this error is: {{ ip }}
</p>
-{% endif %}
<p style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;">
The full stacktrace is below. If you think this is a bug in Firefly III, you
diff --git a/resources/views/emails/error.twig b/resources/views/emails/error.twig
index 28986f90a7..0022c57857 100644
--- a/resources/views/emails/error.twig
+++ b/resources/views/emails/error.twig
@@ -4,8 +4,12 @@ This error occured in file "{{ file }}" on line {{ line }} with code {{ code }}.
{% if loggedIn %}
The error was encountered by user #{{ user.id }}, {{ user.email }}.
+{% else}
+There was no user logged in for this error or no user was detected.
{% endif %}
+The IP address related to this error is: {{ ip }}
+
The full stacktrace is below. If you think this is a bug in Firefly III, you
can forward this message to [email protected]. This can help fix
the bug you just encountered.