Deprecate exceptions.check_message

exceptions.handle() is used in most cases consistently.
check_message() is a legacy which was introduced when exceptions
were not well classified. exceptions.handle() should cover all
common error scenarios and there is no role played by check_messages().
Let's clean up its usage and deprecate it for the future removal.

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: I545b6c666d13d39cf5287ccc7c972dc746faf2fb
Closes-Bug: #1339885
This commit is contained in:
Robin Cernin 2019-04-15 10:22:15 +10:00 committed by Akihiro Motoki
parent 3a829be260
commit 31f7fc6bb2
5 changed files with 5 additions and 5 deletions

View File

@ -22,6 +22,7 @@ import sys
import six
from debtcollector import removals
from django.core.management import color_style
from django.utils import encoding
from django.utils.translation import ugettext_lazy as _
@ -193,6 +194,7 @@ def error_color(msg):
return color_style().ERROR_OUTPUT(msg)
@removals.remove(message='Use exceptions.handle() instead', version='17.2.0')
def check_message(keywords, message):
"""Checks an exception for given keywords and raises an error if found.

View File

@ -43,7 +43,7 @@ class SetAggregateInfoAction(workflows.Action):
aggregates = api.nova.aggregate_details_list(self.request)
except Exception:
msg = _('Unable to get host aggregate list')
exceptions.check_message(["Connection", "refused"], msg)
exceptions.handle(self.request, msg)
raise
if aggregates is not None:
for aggregate in aggregates:

View File

@ -85,7 +85,7 @@ class CreateFlavorInfoAction(workflows.Action):
except Exception:
flavors = []
msg = _('Unable to get flavor list')
exceptions.check_message(["Connection", "refused"], msg)
exceptions.handle(self.request, msg)
raise
if flavors is not None and name is not None:
for flavor in flavors:

View File

@ -66,7 +66,6 @@ class NovaServicesTab(tabs.TableTab):
services = nova.service_list(self.tab_group.request)
except Exception:
msg = _('Unable to get nova services list.')
exceptions.check_message(["Connection", "refused"], msg)
exceptions.handle(self.request, msg)
services = []
return services
@ -87,7 +86,6 @@ class CinderServicesTab(tabs.TableTab):
services = cinder.service_list(self.tab_group.request)
except Exception:
msg = _('Unable to get cinder services list.')
exceptions.check_message(["Connection", "refused"], msg)
exceptions.handle(self.request, msg)
services = []
return services
@ -113,7 +111,6 @@ class NetworkAgentsTab(tabs.TableTab):
agents = neutron.agent_list(self.tab_group.request)
except Exception:
msg = _('Unable to get network agents list.')
exceptions.check_message(["Connection", "refused"], msg)
exceptions.handle(self.request, msg)
agents = []
return agents

View File

@ -10,6 +10,7 @@
pbr!=2.1.0,>=2.0.0 # Apache-2.0
# Horizon Core Requirements
Babel!=2.4.0,>=2.3.4 # BSD
debtcollector>=1.2.0 # Apache-2.0
Django<2,>=1.11;python_version<'3.0' # BSD
Django>=1.11;python_version>='3.0' # BSD
django-babel>=0.6.2 # BSD