wrap repository error in try-catch