summaryrefslogtreecommitdiffstats
path: root/src/grpc/doc/src/qtgrpcclientinterceptor-logging.qdoc
diff options
context:
space:
mode:
authorDennis Oberst <dennis.oberst@qt.io>2024-04-15 13:01:07 +0200
committerDennis Oberst <dennis.oberst@qt.io>2024-04-18 11:14:09 +0200
commit57b875c33bc054fda4c729a063a71ca1ca7cc04e (patch)
tree1d362feabde056146412e9b827358e5ed809305a /src/grpc/doc/src/qtgrpcclientinterceptor-logging.qdoc
parent636b70f93de03dce6ad81fd1d9b27e8a3c43bec8 (diff)
QGrpcOperation: handle failed deserialization directly
Originally motivated by Axivion(SV3), which nagged about the const errorOccurred signal; this patch removes signal emission for failed deserialization in the read() functions. Immediately handling this can lead to better user code as an fallback mechanism can avoid further execution of unneeded logic. This patch makes the errorOcurred signal non-const and changes the signature of the read methods to either return an optional or bool to signal failure immediately. Users can then retrieve the error through 'deserializationError()' or 'deserializationErrorString()'. This can be seen in the generated QML integration code, which uses those to still emit the 'errorOcurred' signal on deserialization failure. Change-Id: Ie6761753145536a42d5dd5bf1eac18afa555581a Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'src/grpc/doc/src/qtgrpcclientinterceptor-logging.qdoc')
-rw-r--r--src/grpc/doc/src/qtgrpcclientinterceptor-logging.qdoc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/grpc/doc/src/qtgrpcclientinterceptor-logging.qdoc b/src/grpc/doc/src/qtgrpcclientinterceptor-logging.qdoc
index 936db77..45ab2a2 100644
--- a/src/grpc/doc/src/qtgrpcclientinterceptor-logging.qdoc
+++ b/src/grpc/doc/src/qtgrpcclientinterceptor-logging.qdoc
@@ -55,8 +55,10 @@ protected:
auto responsePtr = response.get();
QObject::connect(responsePtr, &QGrpcServerStream::messageReceived, responsePtr,
[responsePtr]{
- SimpleStringMessage mess = responsePtr->read<SimpleStringMessage>();
- qDebug() << "Response received:" << mess.testFieldString();
+ const auto mess = responsePtr->read<SimpleStringMessage>();
+ if (!mess)
+ qDebug() << "Failed deserialization";
+ qDebug() << "Response received:" << mess->testFieldString();
});
}
@@ -67,8 +69,8 @@ protected:
// Intercept the response
QObject::connect(stream.get(), &QGrpcServerStream::messageReceived, this,
[stream] {
- SimpleStringMessage mess = stream->read<SimpleStringMessage>();
- qDebug() << "Response received:" << mess.testFieldString();
+ if (const auto mess = responsePtr->read<SimpleStringMessage>())
+ qDebug() << "Response received:" << mess->testFieldString();
});
// Log incoming and outgoing requests here