浏览代码

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

Added PopupException
Enrico Berti 11 年之前
父节点
当前提交
61e8d36
共有 1 个文件被更改,包括 5 次插入1 次删除
  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, {