-
Hello, what do you recommend for handling exceptions in function or operation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@cgsauy The best way to handle exceptions is the Laravel native way, as long as we're talking about HTTP exceptions that can be thrown at any level in the app and then their handling centralised at the exception handler However, if you were to handle certain exceptions to do something upon their occurrence (
|
Beta Was this translation helpful? Give feedback.
@cgsauy The best way to handle exceptions is the Laravel native way, as long as we're talking about HTTP exceptions that can be thrown at any level in the app and then their handling centralised at the exception handler
app/Exceptions/Handler.php
. This is best because it is the most anticipated place for us to find them, and that way handling doesn't get lost in the nesting of the logic.However, if you were to handle certain exceptions to do something upon their occurrence (
try/catch
) you may then decide depending on the responsibility of the handler. For example if you had the following structure:Feature
If the exception had to be gracefully han…