mirror of
https://github.com/ModOrganizer2/modorganizer-installer_fomod_csharp.git
synced 2026-07-27 14:07:20 -07:00
Show deeper exceptions in log when possible.
This commit is contained in:
@@ -90,11 +90,17 @@ IPluginInstaller::EInstallResult executeScript(System::String^ script) {
|
||||
try {
|
||||
auto scriptClass = result->CompiledAssembly->GetType("Script");
|
||||
BaseScript^ scriptObject = (BaseScript^)System::Activator::CreateInstance(scriptClass);
|
||||
auto success = (bool)scriptObject->GetType()->GetMethod("OnActivate")->Invoke(scriptObject, nullptr);
|
||||
auto onActivateMethod = scriptObject->GetType()->GetMethod("OnActivate");
|
||||
|
||||
auto success = (bool)(onActivateMethod->IsStatic ? onActivateMethod->Invoke(nullptr, nullptr) : onActivateMethod->Invoke(scriptObject, nullptr));
|
||||
return success ? IPluginInstaller::EInstallResult::RESULT_SUCCESS : IPluginInstaller::EInstallResult::RESULT_CANCELED;
|
||||
}
|
||||
catch (Exception^ ex) {
|
||||
log::error("C# ({}): {}\n{}", CSharp::to_string(ex->GetType()->FullName), CSharp::to_string(ex->Message), CSharp::to_string(ex->StackTrace));
|
||||
Exception^ innerEx = ex->InnerException;
|
||||
if (innerEx) {
|
||||
log::error("C# ({}): {}\n{}", CSharp::to_string(innerEx->GetType()->FullName), CSharp::to_string(innerEx->Message), CSharp::to_string(innerEx->StackTrace));
|
||||
}
|
||||
return IPluginInstaller::EInstallResult::RESULT_FAILED;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace CSharp {
|
||||
*/
|
||||
inline std::string to_string(System::String^ value) {
|
||||
return msclr::interop::marshal_as<std::string>(value);
|
||||
}
|
||||
inline std::wstring to_wstring(System::String^ value) {
|
||||
return msclr::interop::marshal_as<std::wstring>(value);
|
||||
}
|
||||
inline QString to_qstring(System::String^ value) {
|
||||
return QString::fromStdString(to_string(value));
|
||||
|
||||
Reference in New Issue
Block a user