Commit 682973b3 by Őry Máté

dashboard: handle HumanReadableException in OperationView

parent 588190f6
...@@ -71,7 +71,7 @@ from .tables import ( ...@@ -71,7 +71,7 @@ from .tables import (
NodeListTable, NodeVmListTable, TemplateListTable, LeaseListTable, NodeListTable, NodeVmListTable, TemplateListTable, LeaseListTable,
GroupListTable, UserKeyListTable GroupListTable, UserKeyListTable
) )
from common.models import HumanReadableObject from common.models import HumanReadableObject, HumanReadableException
from vm.models import ( from vm.models import (
Instance, instance_activity, InstanceActivity, InstanceTemplate, Interface, Instance, instance_activity, InstanceActivity, InstanceTemplate, Interface,
InterfaceTemplate, Lease, Node, NodeActivity, Trait, InterfaceTemplate, Lease, Node, NodeActivity, Trait,
...@@ -562,9 +562,13 @@ class OperationView(RedirectToLoginMixin, DetailView): ...@@ -562,9 +562,13 @@ class OperationView(RedirectToLoginMixin, DetailView):
done = False done = False
try: try:
task = self.get_op().async(user=request.user, **extra) task = self.get_op().async(user=request.user, **extra)
except HumanReadableException as e:
e.send_message(request)
logger.exception("Could not start operation")
result = e
except Exception as e: except Exception as e:
messages.error(request, _('Could not start operation.')) messages.error(request, _('Could not start operation.'))
logger.exception(e) logger.exception("Could not start operation")
result = e result = e
else: else:
wait = self.wait_for_result wait = self.wait_for_result
...@@ -575,6 +579,10 @@ class OperationView(RedirectToLoginMixin, DetailView): ...@@ -575,6 +579,10 @@ class OperationView(RedirectToLoginMixin, DetailView):
except TimeoutError: except TimeoutError:
logger.debug("Result didn't arrive in %ss", logger.debug("Result didn't arrive in %ss",
self.wait_for_result, exc_info=True) self.wait_for_result, exc_info=True)
except HumanReadableException as e:
e.send_message(request)
logger.exception(e)
result = e
except Exception as e: except Exception as e:
messages.error(request, _('Operation failed.')) messages.error(request, _('Operation failed.'))
logger.debug("Operation failed.", exc_info=True) logger.debug("Operation failed.", exc_info=True)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment