Add error logging for module initializers

This commit is contained in:
2023-03-05 19:30:29 +02:00
parent 22af41193e
commit c838a800b6

View File

@@ -983,7 +983,15 @@ void ManagedBinaryModule::OnLoaded(MAssembly* assembly)
{ {
if (method->GetParametersCount() == 0) if (method->GetParametersCount() == 0)
{ {
method->Invoke(nullptr, nullptr, nullptr); MObject* exception = nullptr;
method->Invoke(nullptr, nullptr, &exception);
if (exception)
{
MException ex(exception);
String methodName = String(method->GetName());
ex.Log(LogType::Error, methodName.Get());
LOG(Error, "Failed to call module initializer for class {0} from assembly {1}.", String(mclass->GetFullName()), assembly->ToString());
}
} }
} }
} }