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){
}
}