You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When Exceptions::stopIgnoring(ModelNotFoundException::class) is called Laravel will continue to ignore model not found exceptions. This appears to be because ModelNotFoundException extends RecordsNotFoundException which also on the ignore list. When checking whether to ignore an exception Laravel uses instanceof which will return true.
This will also happen for other exception types if their parent is on the ignore list.
How to fix this
I think there two (non-breaking) ways to address this:
Allow developers to tell Laravel to never ignore an exception (e.g. Exceptions::forceReport($e) or Exceptions::withoutIgnoring()->report($e))
Keep an internal "don't ignore list", if an exception is on that list we should always report it, regardless of whether its parents are on the ignore list. Exceptions are added to this list via Exceptions::stopIgnoring(...)
The text was updated successfully, but these errors were encountered:
axlon
changed the title
ModelNotFoundExceptions stay ignored after calling Exceptions::stopIgnoring(...)
ModelNotFoundException stays ignored after calling Exceptions::stopIgnoring(...)Feb 24, 2025
If you setup the reports to ignore RecordsNotFoundException and then you say don't ignore a child of those, the behavior seems ok.
If you would like to change the check from instanceof to $e::class === $ex::class you would lose the ability to ignore all exceptions like RecordsNotFoundException.
A merge between the 2 options could be done but it needs refactoring the logic of dontReport by adding an extra stopIgnoring
Laravel Version
11.40
PHP Version
8.3.14
Database Driver & Version
n/a
Description
Problem
When
Exceptions::stopIgnoring(ModelNotFoundException::class)
is called Laravel will continue to ignore model not found exceptions. This appears to be becauseModelNotFoundException
extendsRecordsNotFoundException
which also on the ignore list. When checking whether to ignore an exception Laravel usesinstanceof
which will returntrue
.This will also happen for other exception types if their parent is on the ignore list.
How to fix this
I think there two (non-breaking) ways to address this:
Exceptions::forceReport($e)
orExceptions::withoutIgnoring()->report($e)
)Exceptions::stopIgnoring(...)
Steps To Reproduce
This should return
true
but returnsfalse
The text was updated successfully, but these errors were encountered: