summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-03-18 11:54:07 -0700
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-05-15 19:10:03 +0200
commitfb40737b0db8ab9f6f7f7ecdc17e5819545f041b (patch)
tree3f3cb41e5e6f815ca2cad773e4069f5727af2843
parentba05af82d3d8b7cbc6e22f93cbf1e3d1575afefe (diff)
downloadqtbase-fb40737b0db8ab9f6f7f7ecdc17e5819545f041b.tar.gz
QProcess/Unix: improve the error message if the child modifier throws
Functionality added for 6.5, but after translatable string freeze. Change-Id: Icfe44ecf285a480fafe4fffd174d984c5349e0cb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/corelib/io/qprocess_unix.cpp8
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp4
2 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index d16fa7498e..669c067430 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -673,8 +673,12 @@ bool QProcessPrivate::processStarted(QString *errorMessage)
}
// did we read an error message?
- if (errorMessage)
- *errorMessage = QLatin1StringView(buf.function) + ": "_L1 + qt_error_string(buf.code);
+ if (errorMessage) {
+ if (buf.code == FakeErrnoForThrow)
+ *errorMessage = QProcess::tr("childProcessModifier() function threw an exception");
+ else
+ *errorMessage = QLatin1StringView(buf.function) + ": "_L1 + qt_error_string(buf.code);
+ }
return false;
}
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index d10c9ea566..f51721e966 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -1486,7 +1486,7 @@ void tst_QProcess::throwInChildProcessModifier()
QVERIFY(!process.waitForStarted(5000));
QCOMPARE(process.state(), QProcess::NotRunning);
QCOMPARE(process.error(), QProcess::FailedToStart);
- QVERIFY2(process.errorString().contains("throw"),
+ QVERIFY2(process.errorString().contains("childProcessModifier"),
qPrintable(process.errorString()));
// try again, to ensure QProcess internal state wasn't corrupted
@@ -1494,7 +1494,7 @@ void tst_QProcess::throwInChildProcessModifier()
QVERIFY(!process.waitForStarted(5000));
QCOMPARE(process.state(), QProcess::NotRunning);
QCOMPARE(process.error(), QProcess::FailedToStart);
- QVERIFY2(process.errorString().contains("throw"),
+ QVERIFY2(process.errorString().contains("childProcessModifier"),
qPrintable(process.errorString()));
#endif
}