Merge "Cleanup for Refactor-error-messages"
This commit is contained in:
commit
467b218810
@ -126,10 +126,10 @@ class CreateVolumeTypeEncryption(forms.SelfHandlingForm):
|
||||
messages.success(request, _('Successfully created encryption for '
|
||||
'volume type: %s') % volume_type_name)
|
||||
return volume_type
|
||||
except Exception as ex:
|
||||
except Exception:
|
||||
redirect = reverse("horizon:admin:volume_types:index")
|
||||
exceptions.handle(
|
||||
request, _('Unable to create encrypted volume type: %s') % ex,
|
||||
request, _('Unable to create encrypted volume type.'),
|
||||
redirect=redirect)
|
||||
|
||||
|
||||
|
@ -127,9 +127,9 @@ class CreateApplicationCredentialForm(forms.SelfHandlingForm):
|
||||
msg = (_('Application credential name "%s" is already used.')
|
||||
% data['name'])
|
||||
messages.error(request, msg)
|
||||
except Exception as ex:
|
||||
except Exception:
|
||||
exceptions.handle(
|
||||
request, _('Unable to create application credential: %s') % ex)
|
||||
request, _('Unable to create application credential.'))
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(CreateApplicationCredentialForm, self).clean()
|
||||
|
@ -52,7 +52,7 @@ class CreateSnapshot(forms.SelfHandlingForm):
|
||||
|
||||
redirect = reverse("horizon:project:instances:index")
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
except Exception as exc:
|
||||
msg = _('Unable to create snapshot: %s') % exc
|
||||
except Exception:
|
||||
msg = _('Unable to create snapshot.')
|
||||
redirect = reverse("horizon:project:instances:index")
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
|
@ -236,14 +236,9 @@ class AttachVolume(forms.SelfHandlingForm):
|
||||
"inst": instance_id,
|
||||
"dev": attach.device}
|
||||
messages.info(request, message)
|
||||
except Exception as ex:
|
||||
except Exception:
|
||||
redirect = reverse('horizon:project:instances:index')
|
||||
if isinstance(ex, api.nova.VolumeMultiattachNotSupported):
|
||||
# Use the specific error from the specific message.
|
||||
msg = str(ex)
|
||||
else:
|
||||
# Use a generic error message.
|
||||
msg = _('Unable to attach volume: %s') % ex
|
||||
msg = _('Unable to attach volume.')
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
return True
|
||||
|
||||
@ -296,10 +291,10 @@ class DetachVolume(forms.SelfHandlingForm):
|
||||
'%(inst)s.') % {"vol": volume,
|
||||
"inst": instance_id}
|
||||
messages.info(request, message)
|
||||
except Exception as ex:
|
||||
except Exception:
|
||||
redirect = reverse('horizon:project:instances:index')
|
||||
exceptions.handle(
|
||||
request, _("Unable to detach volume: %s") % ex,
|
||||
request, _("Unable to detach volume."),
|
||||
redirect=redirect)
|
||||
return True
|
||||
|
||||
|
@ -101,8 +101,8 @@ def network_field_data(request, include_empty_option=False, with_cidr=False,
|
||||
try:
|
||||
networks = api.neutron.network_list_for_tenant(
|
||||
request, tenant_id, **extra_params)
|
||||
except Exception as e:
|
||||
msg = _('Failed to get network list {0}').format(e)
|
||||
except Exception:
|
||||
msg = _('Failed to get network list.')
|
||||
exceptions.handle(request, msg)
|
||||
|
||||
_networks = []
|
||||
|
@ -46,8 +46,9 @@ class UpdateInstanceSecurityGroupsAction(sg_base.BaseSecurityGroupsAction):
|
||||
try:
|
||||
api.neutron.server_update_security_groups(request, instance_id,
|
||||
wanted_groups)
|
||||
except Exception as e:
|
||||
exceptions.handle(request, str(e))
|
||||
except Exception:
|
||||
exceptions.handle(request, _('Unable to update instance security'
|
||||
' group.'))
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -220,10 +220,8 @@ class UpdateSubnet(network_workflows.CreateNetwork):
|
||||
subnet = api.neutron.subnet_update(request, subnet_id, **params)
|
||||
LOG.debug('Subnet "%s" was successfully updated.', data['cidr'])
|
||||
return subnet
|
||||
except Exception as e:
|
||||
msg = (_('Failed to update subnet "%(sub)s": '
|
||||
' %(reason)s') %
|
||||
{"sub": data['cidr'], "reason": e})
|
||||
except Exception:
|
||||
msg = _('Failed to update subnet "%s".') % data['cidr']
|
||||
redirect = reverse(self.failure_url, args=(network_id,))
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
return False
|
||||
|
@ -495,8 +495,7 @@ class CreateNetwork(workflows.Workflow):
|
||||
return network
|
||||
except Exception as e:
|
||||
LOG.info('Failed to create network: %s', e)
|
||||
msg = (_('Failed to create network "%(network)s": %(reason)s') %
|
||||
{"network": data['net_name'], "reason": e})
|
||||
msg = _('Failed to create network "%s".') % data['net_name']
|
||||
redirect = self.get_failure_url()
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
return False
|
||||
@ -565,19 +564,18 @@ class CreateNetwork(workflows.Workflow):
|
||||
self.context['subnet_id'] = subnet.id
|
||||
LOG.debug('Subnet "%s" was successfully created.', data['cidr'])
|
||||
return subnet
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
if network_name:
|
||||
msg = _('Failed to create subnet "%(sub)s" for network '
|
||||
'"%(net)s": %(reason)s')
|
||||
'"%(net)s".')
|
||||
else:
|
||||
msg = _('Failed to create subnet "%(sub)s": %(reason)s')
|
||||
msg = _('Failed to create subnet "%(sub)s".')
|
||||
if no_redirect:
|
||||
redirect = None
|
||||
else:
|
||||
redirect = self.get_failure_url()
|
||||
exceptions.handle(request,
|
||||
msg % {"sub": data['cidr'], "net": network_name,
|
||||
"reason": e},
|
||||
msg % {"sub": data['cidr'], "net": network_name},
|
||||
redirect=redirect)
|
||||
return False
|
||||
|
||||
|
@ -57,6 +57,6 @@ class AddRouterRoute(forms.SelfHandlingForm):
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
except Exception as e:
|
||||
LOG.info('Failed to add route: %s', e)
|
||||
msg = _('Failed to add route: %s') % e
|
||||
msg = _('Failed to add route')
|
||||
redirect = reverse(self.failure_url, args=[router_id])
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
|
@ -54,7 +54,7 @@ class AddInterface(forms.SelfHandlingForm):
|
||||
for fixed_ip in port.fixed_ips]
|
||||
except Exception as e:
|
||||
LOG.info('Failed to get network list: %s', e)
|
||||
msg = _('Failed to get network list: %s') % e
|
||||
msg = _('Failed to get network list.')
|
||||
messages.error(request, msg)
|
||||
if router_id:
|
||||
redirect = reverse(self.failure_url, args=[router_id])
|
||||
@ -170,7 +170,7 @@ class SetGatewayForm(forms.SelfHandlingForm):
|
||||
networks = api.neutron.network_list(request, **search_opts)
|
||||
except Exception as e:
|
||||
LOG.info('Failed to get network list: %s', e)
|
||||
msg = _('Failed to get network list: %s') % e
|
||||
msg = _('Failed to get network list.')
|
||||
messages.error(request, msg)
|
||||
redirect = reverse(self.failure_url)
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
@ -198,6 +198,6 @@ class SetGatewayForm(forms.SelfHandlingForm):
|
||||
except Exception as e:
|
||||
LOG.info('Failed to set gateway to router %(id)s: %(exc)s',
|
||||
{'id': self.initial['router_id'], 'exc': e})
|
||||
msg = _('Failed to set gateway: %s') % e
|
||||
msg = _('Failed to set gateway.')
|
||||
redirect = reverse(self.failure_url)
|
||||
exceptions.handle(request, msg, redirect=redirect)
|
||||
|
@ -76,8 +76,8 @@ class IndexView(tables.DataTableView):
|
||||
**search_opts)
|
||||
ext_net_dict = OrderedDict((n['id'], n.name_or_id)
|
||||
for n in ext_nets)
|
||||
except Exception as e:
|
||||
msg = _('Unable to retrieve a list of external networks "%s".') % e
|
||||
except Exception:
|
||||
msg = _('Unable to retrieve a list of external networks.')
|
||||
exceptions.handle(self.request, msg)
|
||||
ext_net_dict = {}
|
||||
return ext_net_dict
|
||||
|
@ -66,10 +66,9 @@ class GroupBase(forms.SelfHandlingForm):
|
||||
sg = self._call_network_api(request, data)
|
||||
messages.success(request, self.success_message % sg.name)
|
||||
return sg
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
redirect = reverse("horizon:project:security_groups:index")
|
||||
error_msg = self.error_message % e
|
||||
exceptions.handle(request, error_msg, redirect=redirect)
|
||||
exceptions.handle(request, self.error_message, redirect=redirect)
|
||||
|
||||
|
||||
class CreateGroup(GroupBase):
|
||||
|
@ -79,9 +79,9 @@ class PasswordForm(forms.SelfHandlingForm):
|
||||
msg = _("Password changed. Please log in again to continue.")
|
||||
utils.add_logout_reason(request, response, msg)
|
||||
return response
|
||||
except Exception as ex:
|
||||
except Exception:
|
||||
exceptions.handle(request,
|
||||
_('Unable to change password: %s') % ex)
|
||||
_('Unable to change password.'))
|
||||
return False
|
||||
else:
|
||||
messages.error(request, _('Changing password is not supported.'))
|
||||
|
Loading…
Reference in New Issue
Block a user