Return 404 to ajax environment update table call
Before a 404 exception from api was not properly handled and returned 500 error to dashboard ajax call. This resulted in a deleteing environment row being stuck until page reload. Thi patch throws django Http404 in case the row has been deleted successfully and let's other exception to be handled by the universal handler. Also updates the handler to work with non-deprecated version of exceptions from api calls. Change-Id: Iea0a7ebe8589a064da082ceaabd37dd937ac1a5b Closes-Bug: #1481474
This commit is contained in:
parent
c0fcbf2951
commit
32dea0b2fe
|
@ -57,19 +57,19 @@ def handled_exceptions(request):
|
|||
msg = _('Unable to communicate to murano-api server.')
|
||||
LOG.exception(msg)
|
||||
_handle_message(request, msg)
|
||||
except exc.Unauthorized:
|
||||
except exc.HTTPUnauthorized:
|
||||
msg = _('Check Keystone configuration of murano-api server.')
|
||||
LOG.exception(msg)
|
||||
_handle_message(request, msg)
|
||||
except exc.Forbidden:
|
||||
except exc.HTTPForbidden:
|
||||
msg = _('Operation is forbidden by murano-api server.')
|
||||
LOG.exception(msg)
|
||||
_handle_message(request, msg)
|
||||
except exc.NotFound:
|
||||
except exc.HTTPNotFound:
|
||||
msg = _('Requested object is not found on murano server.')
|
||||
LOG.exception(msg)
|
||||
_handle_message(request, msg)
|
||||
except exc.Conflict:
|
||||
except exc.HTTPConflict:
|
||||
msg = _('Requested operation conflicts with an existing object.')
|
||||
LOG.exception(msg)
|
||||
_handle_message(request, msg)
|
||||
|
|
|
@ -16,6 +16,7 @@ import json
|
|||
import logging
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django import http as django_http
|
||||
from django import shortcuts
|
||||
from django.template import defaultfilters
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
@ -252,7 +253,16 @@ class UpdateEnvironmentRow(tables.Row):
|
|||
ajax = True
|
||||
|
||||
def get_data(self, request, environment_id):
|
||||
return api.environment_get(request, environment_id)
|
||||
try:
|
||||
return api.environment_get(request, environment_id)
|
||||
except exc.HTTPNotFound:
|
||||
# returning 404 to the ajax call removes the
|
||||
# row from the table on the ui
|
||||
raise django_http.Http404
|
||||
except Exception:
|
||||
# let our unified handler take care of errors here
|
||||
with api_utils.handled_exceptions(request):
|
||||
raise
|
||||
|
||||
|
||||
class UpdateServiceRow(tables.Row):
|
||||
|
|
Loading…
Reference in New Issue