Browse Source

HUE-2141 [search] Fail gracefully when a collection does not exist

Added PopupException
Enrico Berti 11 năm trước cách đây
mục cha
commit
61e8d36
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  1. 5 1
      apps/search/src/search/views.py

+ 5 - 1
apps/search/src/search/views.py

@@ -55,7 +55,11 @@ def index(request):
     else:
       return no_collections(request)
 
-  collection = Collection.objects.get(id=collection_id) # TODO perms HUE-1987
+  try:
+    collection = Collection.objects.get(id=collection_id) # TODO perms HUE-1987
+  except Exception, e:
+    raise PopupException(e, title=_('Error while accessing the collection'))
+
   query = {'qs': [{'q': ''}], 'fqs': [], 'start': 0}
 
   return render('search.mako', request, {