laravel / ideas

Issues board used for Laravel internals discussions.
938 stars 28 forks source link

Always log error when using report() helper #2579

Closed garygreen closed 3 years ago

garygreen commented 3 years ago

At the moment whenever you use the report() helper function it will only log the exception if your ExceptionHandler has essentially whitelisted that exception.

This was suprising to us in our application because whenever you're manually calling report() you would expect it to do just that - log the exception. However it wasn't because it was on the dontReport list in the ExceptionHandler

$e = new HttpException(HTTP_CODES::TOO_MANY_REQUESTS, 'Your doing that too fast.');
report($e); // You would expect this to log the exception.
            // ...but by default it doesn't because HttpExceptions are not logged.

So would it make more sense to always log exceptions that have been reported manually with report()? This function is practically only used when you are specifically wanting to report an exception. So your logic when to report the exception should surround the report call itself.

themsaid commented 3 years ago

That's the expected behaviour yes. The report() helper uses the Exception handler and if you choose not to log an Exception Laravel will do just that.