]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Enhance exception translation to better handle NeutronExceptions
authorLuis A. Garcia <luis@linux.vnet.ibm.com>
Fri, 16 Aug 2013 16:07:47 +0000 (16:07 +0000)
committerGerrit Code Review <review@openstack.org>
Thu, 12 Sep 2013 18:43:15 +0000 (18:43 +0000)
commit7e2622c2fc89611a34c242792f46572545bcdffb
tree72913e15a489bd41ddbc89446fe24747a12f2ead
parentca99b92719817a77b84286617d0da0b0e3e080ba
Enhance exception translation to better handle NeutronExceptions

NeutronExceptions have a 'message' class attribute that holds the
generic error message template, e.g. "Network %(network)s not found",
unfortunately, because the names are the same, it was overshadowing the
actual exception instance 'message', e.g. "Network 1 not found", after
translation when the exception was serialized to JSON.

This patch puts the exception's actual message in a new field called
'msg' and overwrites NeutronException unicode() so that 'msg' is used
during serialization and we'll get the correct message on the REST API
response.

Fixes bug: #1212882

Change-Id: I3965bffb1c2c2eee0af440d1ecd30ccb3bb958d5
neutron/api/v2/resource.py
neutron/common/exceptions.py
neutron/tests/unit/test_api_v2_resource.py