Added exception handling to SerializeProperty.TrySetValue methods
This commit is contained in:
@@ -130,8 +130,16 @@ namespace Barotrauma
|
|||||||
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + obj + "\" to " + value + " (not a valid " + propertyInfo.PropertyType + ")", e);
|
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + obj + "\" to " + value + " (not a valid " + propertyInfo.PropertyType + ")", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
propertyInfo.SetValue(obj, enumVal);
|
propertyInfo.SetValue(obj, enumVal);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + obj.ToString() + "\" to " + value.ToString(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + obj + "\" to " + value);
|
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + obj + "\" to " + value);
|
||||||
@@ -141,6 +149,8 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
switch (typeName)
|
switch (typeName)
|
||||||
{
|
{
|
||||||
case "bool":
|
case "bool":
|
||||||
@@ -179,6 +189,14 @@ namespace Barotrauma
|
|||||||
propertyInfo.SetValue(obj, XMLExtensions.ParseRect(value, true));
|
propertyInfo.SetValue(obj, XMLExtensions.ParseRect(value, true));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + obj.ToString() + "\" to " + value.ToString(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -215,6 +233,8 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (value.GetType() == typeof(string))
|
if (value.GetType() == typeof(string))
|
||||||
{
|
{
|
||||||
switch (typeName)
|
switch (typeName)
|
||||||
@@ -251,6 +271,14 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
propertyInfo.SetValue(obj, value, null);
|
propertyInfo.SetValue(obj, value, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugConsole.ThrowError("Failed to set the value of the property \"" + Name + "\" of \"" + obj.ToString() + "\" to " + value.ToString(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|||||||
Reference in New Issue
Block a user