Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions MMCore/MMCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#include <set>
#include <sstream>
#include <thread>
#include <typeinfo>
#include <vector>

namespace mmi = mmcore::internal;
Expand Down Expand Up @@ -7667,6 +7668,76 @@ void CMMCore::loadSystemConfiguration(const char* fileName) MMCORE_LEGACY_THROW(
"Now rethrowing original error from system configuration loading";
throw;
}
catch (const std::exception& e)
{
// A device adapter (or other code below us) threw a C++ standard
// exception. There is no SWIG typemap for these, so allowing one to
// escape through the JNI boundary terminates the whole JVM with an
// EXCEPTION_UNCAUGHT_CXX_EXCEPTION hs_err file and no usable
// diagnostic. Log what we know and translate to CMMError, which does
// have a typemap and so surfaces as a normal error to the application.
isLoadingSystemConfiguration_ = false;
Comment on lines +7671 to +7679

const std::string exceptionType = typeid(e).name();
const std::string exceptionWhat = e.what();

LOG_ERROR(coreLogger_) <<
"Unhandled C++ exception while loading system configuration: " <<
exceptionType << ": " << exceptionWhat;

LOG_INFO(coreLogger_) <<
"Unloading all devices after failure to load system configuration";

try
{
unloadAllDevices();
}
catch (const CMMError& err)
{
LOG_ERROR(coreLogger_) <<
"Error occurred while unloading all devices: " <<
err.getFullMsg();
}
catch (const std::exception& err)
{
LOG_ERROR(coreLogger_) <<
"Unhandled C++ exception while unloading all devices: " <<
err.what();
}
Comment on lines +7691 to +7706

throw CMMError("Unhandled C++ exception while loading system "
"configuration (" + exceptionType + "): " + exceptionWhat);
}
catch (...)
{
// Same rationale as above, for exceptions not derived from
// std::exception. We cannot say anything about the value, but turning
// this into a CMMError still beats terminating the process.
isLoadingSystemConfiguration_ = false;

LOG_ERROR(coreLogger_) <<
"Unhandled non-standard C++ exception while loading system "
"configuration";

try
{
unloadAllDevices();
}
catch (const CMMError& err)
{
LOG_ERROR(coreLogger_) <<
"Error occurred while unloading all devices: " <<
err.getFullMsg();
}
catch (...)
{
LOG_ERROR(coreLogger_) <<
"Unhandled exception while unloading all devices";
}

throw CMMError("Unhandled non-standard C++ exception while loading "
"system configuration");
}

postNotification(notif::SystemConfigurationLoaded{});
}
Expand Down
Loading