Skip to content

Commit a9cace9

Browse files
committed
Catch and log no project exception
1 parent 97c4f48 commit a9cace9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

readthedocs/core/views.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,12 @@ def github_build(request):
227227
ghetto_url = url.replace('http://', '').replace('https://', '')
228228
branch = obj['ref'].replace('refs/heads/', '')
229229
pc_log.info("(Incoming Github Build) %s [%s]" % (ghetto_url, branch))
230-
return _build_url(ghetto_url, [branch])
230+
try:
231+
return _build_url(ghetto_url, [branch])
232+
except NoProjectException:
233+
pc_log.error(
234+
"(Incoming GitHub Build) Repo not found: %s" % ghetto_url)
235+
return HttpResponseNotFound('Repo not found: %s' % ghetto_url)
231236
else:
232237
return HttpResponse("You must POST to this resource.")
233238

@@ -263,7 +268,12 @@ def generic_build(request, pk=None):
263268
project = Project.objects.get(pk=pk)
264269
# Allow slugs too
265270
except (Project.DoesNotExist, ValueError):
266-
project = Project.objects.get(slug=pk)
271+
try:
272+
project = Project.objects.get(slug=pk)
273+
except (Project.DoesNotExist, ValueError):
274+
pc_log.error(
275+
"(Incoming Generic Build) Repo not found: %s" % pk)
276+
return HttpResponseNotFound('Repo not found: %s' % pk)
267277
if request.method == 'POST':
268278
slug = request.POST.get('version_slug', None)
269279
if slug:

0 commit comments

Comments
 (0)