def _make_inventory_object(resource_provider, resource_class, **data):
 try:
  inventory = objects.Inventory(resource_provider=resource_provider, resource_class=resource_class, **data)
 except (ValueError, TypeError) as exc:
  raise webob.exc.HTTPBadRequest((_('Bad inventory %(class)s for resource provider %(rp_uuid)s: %(error)s') % {'class': resource_class, 'rp_uuid': resource_provider.uuid, 'error': exc}), json_formatter=util.json_error_formatter)
 return inventory

def _make_inventory_object ( resource_provider , resource_class , ** data ) : try : inventory = objects . Inventory ( resource_provider = resource_provider , resource_class = resource_class , ** data ) except ( ValueError , TypeError ) as exc : raise webob . exc . HTTPBadRequest ( ( _ ( 'Bad inventory %(class)s for resource provider %(rp_uuid)s: %(error)s' ) % { 'class' : resource_class , 'rp_uuid' : resource_provider . uuid , 'error' : exc } ) , json_formatter = util . json_error_formatter ) return inventory
single place to catch malformed inventories .