Add type information to ObjectNotFound message
This patch improves the ObjectNotFound exception message thrown by Neutron objects DB API. Before: Object subnet_id:: 8426f11e-fef0-4432-af46-94c7177ee742\ address:: fhbjxrjhsq not found. After: Object DNSNameServer(subnet_id=8426f11e-fef0-4432-af46-94c7177ee742,\ address=fhbjxrjhsq) not found. Change-Id: Iab49666bc30409d81556c529317f060d59671c5f Partially-Implements: blueprint adopt-oslo-versioned-objects-for-db
This commit is contained in:
@@ -56,9 +56,9 @@ def _safe_get_object(context, model, **kwargs):
|
||||
db_obj = get_object(context, model, **kwargs)
|
||||
|
||||
if db_obj is None:
|
||||
key = "".join(['%s:: %s ' % (key, value) for (key, value)
|
||||
in kwargs.items()])
|
||||
raise n_exc.ObjectNotFound(id=key)
|
||||
key = ", ".join(['%s=%s' % (key, value) for (key, value)
|
||||
in kwargs.items()])
|
||||
raise n_exc.ObjectNotFound(id="%s(%s)" % (model.__name__, key))
|
||||
return db_obj
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user