Would it be better to refactor the same behavior (try-catch) into one function?