Proper way to handle Exceptions #32810
-
What I am trying to do is build a Stripe-specific exception class to handle any Stripe-related exception:
I would like to move all this exception logic (for Stripe) from my Controller above into an exception class. What is the correct (Laravel) way to handle exceptions? How would you do it? Some context: When Laravel 7.x came out, according to the upgrade guide I believe there was a symfony-related update on how exceptions were handled. Not sure if the php artisan make:exception command has been updated, but running
However, if you look at app\Exceptions\Handler.php it looks more like this
Confused how to proceed - how would you build the exception class for Stripe? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You should just be able to php artisan make:exception [NameOfException] then add logic to the render method and it should just work. I've never utilized custom exception classes, but it should work. There's no reason for the template to match the exception handler class above, just add the render or report methods as you need them. |
Beta Was this translation helpful? Give feedback.
You should just be able to php artisan make:exception [NameOfException] then add logic to the render method and it should just work. I've never utilized custom exception classes, but it should work. There's no reason for the template to match the exception handler class above, just add the render or report methods as you need them.