In Python, there is this useful exception handling code:
try:
# Code that could raise an exception
except Exception:
# Exception handling
else:
# Cod
if (!IsReadOnly)
{
T newobj;
bool Done;
try
{
newobj = DataPortal.Update(this);
List keys = new List(BasicProperties.Keys);
foreach (string key in keys)
{
BasicProperties[key] = newobj.BasicProperties[key];
}
Done = true;
}
catch (DataPortalException)
{
// TODO: Implement DataPortal.Update() recovery mechanism
Done = false;
}
finally
{
if (newobj != null && Done == false)
{
List keys = new List(BasicProperties.Keys);
foreach (string key in keys)
{
BasicProperties[key] = newobj.BasicProperties[key];
}
}
}
}