Answer the question
In order to leave comments, you need to log in
How to catch exceptions in multiple methods?
There are two methods that return an object and, accordingly, can be called by a chain (the call goes in the controller), for example
$object->upload()->resize();
Each of the methods contains its own exceptions. Now I have a try-catch block in each method.
public function first()
{
try {
} catch {
}
}
public function second()
{
try {
} catch {
}
}
Answer the question
In order to leave comments, you need to log in
The question is strange. Which outlet should I plug the kettle into? The one closer!
It is correct to write a try-catch block where you need to catch an exception.
If you need to catch an exception in the controller, catch it in the controller.
If it is necessary to catch in a method - to catch in a method.
If you need to catch any exception in the program - either in the global try-catch block or in the exception handler.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question