How to catch exceptions in multiple methods?

There are two methods that return an object and, accordingly, can be called a chain (call goes to the controller), for example
$object->upload()->resize();
Each method contains a call to its own exceptions. Now I have a try-catch block is written in each method.
public function first()
{
 try {

 } catch {

}
}

public function second()
{
 try {

 } catch {

}
}

How to make a try-catch block outside methods, but it does not insert try-catch in the controller?
April 7th 20 at 10:56
1 answer
April 7th 20 at 10:58
Solution
The question is strange. Which outlet I stick the kettle on? That is closer!

How to write a try-catch block where it is necessary to catch the exception.
If you want to catch the exception in the controller to catch in the controller.
If you need to catch in the method - catch in the method.
If you need to catch any exception in the program or in a global try-catch block, or exaplin the handler.
Yes, a little odd, just thought mirroring try-catch block in each method is not good, now read about the handler in Laravel, like what I was looking for. Thanks for the tip :) - Conrad.Kuhlm commented on April 7th 20 at 11:01
@Conrad.Kuhlm, if you really really need to get everywhere (and not a global handler), you can wrap the function with colbeck, who catches them and throws need/returns the result. - Loma.Trantow commented on April 7th 20 at 11:04

Find more questions by tags PHPExceptions