Handle errors on API when a project does not have a repository
Created by: jubianchi
This is basically a fix for #6289 (closed): when a project does not have a repository (i.e no refs have been pushed) API was giving badly formatted errors.
It will now return 404 errors when appropriate