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
Can't really wrap my head around this one, when I try to throw an exception from the Laravel Jetstream's TeamPolicy, I get a Symfony\Component\ErrorHandler\Error\FatalError - Uncaught App\Exceptions\PlanLimitReached
Throwing the same exception on other resources don't cause any issue so I suppose it's Jetstream related
App/Policies/TeamPolicy.php
public function create()
{
throw new PlanLimitReached();
}
App/Exceptions/PlanLimitReached.php
class PlanLimitReached extends Exception
{
public function render($request)
{
if ($request->expectsJson()) {
return response()->json([
'error' => 'PlanLimitReached',
'message' => 'You reached the limitation for your current billing plan, please upgrade your account.'
], 403);
}
return Inertia::render('User/Billing/LimitReached');
}
}
If I return false in the exception's render method, it does work but I would like to have my custom exception involved instead of a generic 403 error :/
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
Can't really wrap my head around this one, when I try to throw an exception from the Laravel Jetstream's TeamPolicy, I get a Symfony\Component\ErrorHandler\Error\FatalError - Uncaught App\Exceptions\PlanLimitReached
Throwing the same exception on other resources don't cause any issue so I suppose it's Jetstream related
App/Policies/TeamPolicy.php
App/Exceptions/PlanLimitReached.php
The exception:
https://flareapp.io/share/Lm8AkqbP
If I return false in the exception's render method, it does work but I would like to have my custom exception involved instead of a generic 403 error :/
Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions