Replies: 3 comments 1 reply
-
|
Hey, I think the problem with a single A more composable approach would be to allow individual exception classes to declare a class MyException extends \Exception
{
public function loggableMessage(): string
{
return 'Database query failed';
}
}The handler checks for this method before falling back to |
Beta Was this translation helpful? Give feedback.
-
|
Alternatively to @Pola5h's solution, there could be a |
Beta Was this translation helpful? Give feedback.
-
|
Fair point @shaedrich, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When an exception bubbles up to the the Laravel exception handler, the following code in
reportThrowableis called:My suggestion is to, instead, allow the developer to provide a default log message:
When using a log aggregation system, we alert on logs with
ERRORlevel.This sometimes produces too many alerts, so we group logs with the same message before firing the alert.
However, this doesn't work well with the default logging behavior because the exception messages contain very specific information, e.g.:
The way we currently deal with this is we have overridden the reporting for every specific exception we see. This is not ideal because we have to remember to do this for every new exception, otherwise we might get an alert flood
We've also considered overriding the entire handler but
reportThrowablehas the exception level and exception context logic that we'd have to replicate in our implementation and maintain for framework updates.It would be better if the framework provided out of the box.
Beta Was this translation helpful? Give feedback.
All reactions