Show deeper exceptions in log when possible.

This commit is contained in:
Mikaël Capelle
2020-05-24 23:48:38 +02:00
parent 853557fe4e
commit 19348bd3a4
2 changed files with 10 additions and 1 deletions
+7 -1
View File
@@ -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;
}
+3
View File
@@ -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));