Improve repository error check