From 6d3d624980cf129af898e9ad8f842380c4842d0c Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 30 Jan 2021 21:15:49 +0200 Subject: [PATCH] Improve error handling for final measurements placeholders. #85 --- src/libs/vlayout/vtextmanager.cpp | 6 ++++-- src/libs/vtools/dialogs/support/dialogeditlabel.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libs/vlayout/vtextmanager.cpp b/src/libs/vlayout/vtextmanager.cpp index ddabcc98c..b32648954 100644 --- a/src/libs/vlayout/vtextmanager.cpp +++ b/src/libs/vlayout/vtextmanager.cpp @@ -263,8 +263,10 @@ QMap PreparePlaceholders(const VAbstractPattern *doc, const VC } catch (qmu::QmuParserError &e) { - qCritical("%s\n\n%s", qUtf8Printable(QObject::tr("Failed to prepare final measurement placeholder.")), - qUtf8Printable(QObject::tr("Parser error at line %1: %2.").arg(i+1).arg(e.GetMsg()))); + const QString errorMsg = QObject::tr("Failed to prepare final measurement placeholder. Parser error at " + "line %1: %2.").arg(i+1).arg(e.GetMsg()); + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } } } diff --git a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp index ab65cf3c2..55b5f2ba9 100644 --- a/src/libs/vtools/dialogs/support/dialogeditlabel.cpp +++ b/src/libs/vtools/dialogs/support/dialogeditlabel.cpp @@ -580,8 +580,10 @@ void DialogEditLabel::InitPlaceholders() } catch (qmu::QmuParserError &e) { - qCritical("%s\n\n%s", qUtf8Printable(QObject::tr("Failed to prepare final measurement placeholder.")), - qUtf8Printable(QObject::tr("Parser error at line %1: %2.").arg(i+1).arg(e.GetMsg()))); + const QString errorMsg = QObject::tr("Failed to prepare final measurement placeholder. Parser error at " + "line %1: %2.").arg(i+1).arg(e.GetMsg()); + qApp->IsPedantic() ? throw VException(errorMsg) : + qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg; } } }