2 #include "ScopeException.h"
3 #include "FPGAException.h"
4 #include "controllers/ScopeLogger.h"
8 void ScopeExceptionHandler(
const std::string& _origin,
const bool& _log,
const bool& _showmessagebox,
const bool& _trace,
const bool& _rethrow) {
14 std::string msg =
"A Scope exception happened in " + _origin +
":\r\n" + ex.what();
19 std::string msg =
"An FPGA exception happened in " + _origin +
":\r\n" +
"Status code: " + std::to_string(static_cast<long long>(ex.
fpga_status)) +
" Message: " + ex.what();
23 catch (
const boost::property_tree::ptree_bad_path& bp) {
24 std::string msg =
"A property tree exception happened in " + _origin +
":\r\n";
25 msg +=
"The parameter \"" + bp.path<boost::property_tree::wpath>().dump() +
"\" could not be found in the xml file.";
29 catch (
const std::bad_cast& exbc) {
30 std::string msg =
"A bad cast exception happened in " + _origin +
":\r\n" + exbc.what() +
"\r\n\r\n Most probably ScopeDefines.h is misconfigured. Exit immediately.";
34 catch (
const std::bad_alloc& exba) {
35 std::string msg =
"A bad allocation exception happened int " + _origin +
":\r\n" + exba.what() +
"\r\n\r\n Most probably there is not enough memory to allocate for Scope. Exit immediately.";
39 catch (
const std::exception& exstd) {
40 std::string msg =
"A STL exception happened in " + _origin +
":\r\n" + exstd.what();
44 catch (
const _com_error& comerr) {
45 std::string msg =
"A COM error happened in " + std::string(CW2A(comerr.Source())) +
"\r\n\r\n" + std::string(CW2A(comerr.Description()));
49 std::string msg =
"An unkown exception happened in " + _origin +
"\r\nThis is serious. Exit Scope immediately.";
57 DBOUT(CA2W(_msg.c_str()));
62 scope_logger.
Log(std::wstring(CA2W(_msg.c_str())), log_error);
65 if ( _showmessagebox )
66 ::MessageBoxA(NULL, _msg.c_str(),
"ScopeException", MB_OK | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
76 scope_logger.
Log(_msg, log_error);
79 if ( _showmessagebox )
80 ::MessageBoxW(NULL, _msg.c_str(), L
"ScopeException", MB_OK | MB_ICONWARNING | MB_TASKMODAL | MB_SETFOREGROUND | MB_TOPMOST);
Simple exception class for Scope.
An exception for FPGA stuff.
const int32_t fpga_status
the FPGA status
void __ScopeExceptionHandlerHelper(const std::string &_msg, const bool &_log, const bool &_showmessagebox, const bool &_trace)
Helper function that actually handles the logging to the ScopeLogger.
A logger class to log various messages and user comments.
void __ScopeExceptionHandlerHelperW(const std::wstring &_msg, const bool &_log, const bool &_showmessagebox, const bool &_trace)
Helper function that actually handles the logging to the ScopeLogger (wide string version) ...
This is the include file for standard system include files, or project specific include files that ar...
void Log(const std::wstring &message, const log_message_type &msgtype)
Logs a message.
#define DBOUT(s)
A debug output to the debug console.
void ScopeExceptionHandler(const std::string &_origin, const bool &_log, const bool &_showmessagebox, const bool &_trace, const bool &_rethrow)
Handles all exceptions and does nice logging.