From fb40737b0db8ab9f6f7f7ecdc17e5819545f041b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 18 Mar 2023 11:54:07 -0700 Subject: 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 Reviewed-by: Volker Hilsheimer --- src/corelib/io/qprocess_unix.cpp | 8 ++++++-- tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 4 ++-- 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 } -- cgit v1.2.1