mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Catch Activator exceptions
This commit is contained in:
@@ -323,7 +323,24 @@ public static class EntitySerializer
|
|||||||
if (type == null)
|
if (type == null)
|
||||||
return context;
|
return context;
|
||||||
|
|
||||||
context._instance = Activator.CreateInstance(type);
|
try
|
||||||
|
{
|
||||||
|
context._instance = Activator.CreateInstance(type, true);
|
||||||
|
}
|
||||||
|
catch (MissingMethodException e)
|
||||||
|
{
|
||||||
|
Log.Error($"Failed to create instance of type \"{type}\": The type doesn't contain a constructor with zero parameters.\nMake sure the type has a constructor that takes no arguments (It can be private!).\n{e}");
|
||||||
|
}
|
||||||
|
catch (MethodAccessException e)
|
||||||
|
{
|
||||||
|
Log.Error($"Failed to create instance of type \"{type}\": The default constructor is not accessible.\n{e}");
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.Error(e);
|
||||||
|
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
if (context._instance == null)
|
if (context._instance == null)
|
||||||
return context;
|
return context;
|
||||||
|
|||||||
Reference in New Issue
Block a user