13 #ifndef QmitkSafeNotify_h
14 #define QmitkSafeNotify_h
19 #include <QMessageBox>
43 return app->A::notify(receiver, event);
47 msg = QString(
"MITK Exception:\n\n") + QString(
"Description: ") + QString(e.GetDescription()) + QString(
"\n\n") +
48 QString(
"Filename: ") + QString(e.GetFile()) + QString(
"\n\n") + QString(
"Line: ") +
49 QString::number(e.GetLine());
51 catch (std::exception &e)
57 msg =
"Unknown exception";
59 MITK_ERROR <<
"An error occurred: " << msg.toStdString();
62 msgBox.setText(
"An error occurred. You should save all data and quit the program to prevent possible data loss.");
63 msgBox.setDetailedText(msg);
64 msgBox.setIcon(QMessageBox::Critical);
65 msgBox.addButton(
"Exit immediately", QMessageBox::YesRole);
66 msgBox.addButton(
"Ignore", QMessageBox::NoRole);
68 int ret = msgBox.exec();
74 std::exit(EXIT_FAILURE);
77 <<
"The error was ignored by the user. The program may be in a corrupt state and don't behave like expected!";
bool QmitkSafeNotify(A *app, QObject *receiver, QEvent *event)
Safely delivers a Qt event, catching and displaying any exceptions.
Base class for all MITK exceptions.
#define MITK_ERROR
Log an error message.