def heat_exceptions(error_message): try: yield except heat_exc.NotFound as e: raise exc.OpenStackCloudResourceNotFound("{msg}: {exc}".format( msg=error_message, exc=str(e))) except Exception as e: raise exc.OpenStackCloudException("{msg}: {exc}".format( msg=error_message, exc=str(e)))
def neutron_exceptions(error_message): try: yield except neutron_exc.NotFound as e: raise exc.OpenStackCloudResourceNotFound("{msg}: {exc}".format( msg=error_message, exc=str(e))) except neutron_exc.NeutronClientException as e: if e.status_code == 404: raise exc.OpenStackCloudURINotFound("{msg}: {exc}".format( msg=error_message, exc=str(e))) else: raise exc.OpenStackCloudException("{msg}: {exc}".format( msg=error_message, exc=str(e))) except Exception as e: raise exc.OpenStackCloudException("{msg}: {exc}".format( msg=error_message, exc=str(e)))