Respond with 404 if job doesn't have a repository

We have some jobs which doesn't have any repository in our DB. This is a
quick fix which returns 404 for such a request instead of raising an
error
This commit is contained in:
Piotr Sarnacki 2014-10-01 20:39:50 +02:00
parent 21485d8851
commit dd239b86d0

View File

@ -12,7 +12,14 @@ class Travis::Api::App
end
get '/:id' do
respond_with service(:find_job, params)
job = service(:find_job, params).run
if job && job.repository
respond_with job
else
json = { error: { message: "The job(#{params[:id]}) couldn't be found" } }
status 404
respond_with json
end
end
post '/:id/cancel' do