I'm new to Python exception handling. How do I correctly try
the following, except
if .get_entity
fails, but pass if Status 200
?
Here is where I'm at:
- Its not correct though. Hoping you could elaborate with an example.
from azure.cosmosdb.table.tableservice import TableService
from azure.cosmosdb.table.models import Entity
from azure.common import AzureMissingResourceHttpError
def get_table_row(TableName, PartitionKey, RowKey):
try:
table_lookup = table_service.get_entity(TableName, PartitionKey, RowKey)
except AzureMissingResourceHttpError as e:
logging.error(f'#### Status Code: {e.status_code} ####')
finally:
if e.status_code == 200:
return table_lookup
else:
logging.error(f'#### Status Code: {e.status_code} ####')
data = get_table_row(TableName, PartitionKey, RowKey)