如何使用函数保持代码清洁的示例

I have code that requires a lot of repeated code such as try and catch exceptions. Looking at the code below could I put the try and catch exception into a function to keep it clean?

public function home(){

 try{
        $variable     = DB::table($tableone)->first();
         }catch(\Exception $e){
 }

//some code
 try {
        $variabletwo   = DB::table($tabletwo)->first();
         }catch(\Exception $e){
 }
//some code
 try {
        $variablethree    = DB::table($tablethree)->first();   
        }catch(\Exception $e){
     }

}
function GetFirst($tbl) {
    try
    {
        return DB::table($tbl)->first();
    }
    catch (Exception $e) 
    { ... }
}

$variableone = GetFirst($tableone);
$variabletwo = GetFirst($tabletwo);

You should only make one try catch for the whole block. You can refer to this answer for best practice on try catch.