Catch repo exceptions

I investigated #1859, but was not able to reproduce the problem exactly, because I do see error messages either when the assignment folder or entire repo is missing. 

I fixed those problems crudely, and will investigate further later.
Trailing whitespace detected.