From 2ca2595968cabe31dac60f9eb91cf294c83decb4 Mon Sep 17 00:00:00 2001 From: dismine Date: Mon, 3 Mar 2014 17:42:14 +0200 Subject: [PATCH] Refactoring catching exceptions. --HG-- branch : feature --- src/widgets/vapplication.cpp | 58 +++++------------------------------- 1 file changed, 7 insertions(+), 51 deletions(-) diff --git a/src/widgets/vapplication.cpp b/src/widgets/vapplication.cpp index 0a4d7eaca..16664f94a 100644 --- a/src/widgets/vapplication.cpp +++ b/src/widgets/vapplication.cpp @@ -45,77 +45,33 @@ bool VApplication::notify(QObject *receiver, QEvent *event) } catch (const VExceptionObjectError &e) { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error parsing file. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); + e.CriticalMessageBox(tr("Error parsing file. Program will be terminated.")); abort(); } catch (const VExceptionBadId &e) { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error bad id. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); + e.CriticalMessageBox(tr("Error bad id. Program will be terminated.")); abort(); } catch (const VExceptionConversionError &e) { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error can't convert value. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); + e.CriticalMessageBox(tr("Error can't convert value. Program will be terminated.")); abort(); } catch (const VExceptionEmptyParameter &e) { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error empty parameter. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); + e.CriticalMessageBox(tr("Error empty parameter. Program will be terminated.")); abort(); } catch (const VExceptionWrongParameterId &e) { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Error wrong id. Program will be terminated.")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setDetailedText(e.DetailedInformation()); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); + e.CriticalMessageBox(tr("Error wrong id. Program will be terminated.")); abort(); } catch (const VException &e) { - QMessageBox msgBox; - msgBox.setWindowTitle(tr("Error!")); - msgBox.setText(tr("Something's wrong!!")); - msgBox.setInformativeText(e.ErrorMessage()); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Critical); - msgBox.exec(); + e.CriticalMessageBox(tr("Something's wrong!!")); + return true; } catch (std::exception& e) {