-
-
Notifications
You must be signed in to change notification settings - Fork 480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception doesn't go through Handler #4486
Comments
Are you registering your callback for Sentry based on the Laravel 8 exception handler? Using the Sentry docs you are supposed to register it within a |
@jelleroorda This problem is not only related to Sentry. But yes, I also tried to registering the callback as in the Sentry docs (and the Laravel 8 exception handler). Doesn't work. |
I've checked why, and it turns out that there's a middleware that swaps out the exception handler for a ApiExceptionHandler. I'm not completely sure why that was done though. The only thing I can see is that it might have something to do with testing. For now you can work around it by adding something like this in your $this->app->resolving(\Illuminate\Contracts\Debug\ExceptionHandler::class, function($handler) {
$handler->reportable(function(\Throwable $e) {
dd('exception', $e);
});
}); It'll register your reportable handler for both exception handlers. Maybe @jasonvarga has a better solution or can explain why we need the ApiExceptionHandler? |
@jelleroorda Good catch! I would be also interested in why the exception handler has been swapped out. @jasonvarga please give us some insight 👨💻 |
Okay, I found something in the commit message 9be827c
|
From what I can see, maybe we could take this api rendering part and add it in the NotFoundHttpException@render method inside a manual check for whether it's an api route. Let's wait for Jason for now 😄 |
It was done so that we could control responses for CP and API errors. So yes if we can continue to use the appropriate responses without using our custom handlers... we can avoid swapping the handlers. |
Bug description
I came across some exception that will be ignored by the
app\Exceptions\Handler.php
and will be directly handled byIlluminate\Foundation\Exceptions\Handler
.Therefore logging to external services (e.g. Sentry) will not work.
I don't know if this is Statamic specific or is a problem related to Laravel, but I thought I'm gonna open an issue so you can have a look.
How to reproduce
statamic/starter-kit-starters-creek
statamic instance.config/statamic/api.php
/api/collections/blog/entries?filter[date:is_past]=abc
app\Exceptions\Handler.php
:/api/collections/blog/entries?filter[date:is_past]=abc
againdd()
will be ignored.Logs
Versions
Statamic 3.2.10 Pro
Laravel 8.62.0
PHP 7.4.24
statamic/ssg 0.8.0
Installation
Starter Kit using via CLI
Additional details
statamic new mysite statamic/starter-kit-starters-creek
The text was updated successfully, but these errors were encountered: