From 3be88f8336b46dc66933e25bc4d7f4b5999d1d6b Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Fri, 16 Jun 2023 18:08:39 +0200 Subject: [PATCH] [chip-tool] The error is not reported over websocket when a read/subscribe action has a global error (#27040) --- examples/chip-tool/commands/clusters/ClusterCommand.h | 6 +++--- examples/chip-tool/commands/clusters/ReportCommand.h | 10 ++++++---- .../commands/clusters/WriteAttributeCommand.h | 4 ++-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index eb9a7167948bf5..6b68e1b04bfea0 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -74,7 +74,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub CHIP_ERROR error = status.ToChipError(); if (CHIP_NO_ERROR != error) { - ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); + LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error)); mError = error; @@ -83,7 +83,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub if (data != nullptr) { - ReturnOnFailure(RemoteDataModelLogger::LogCommandAsJSON(path, data)); + LogErrorOnFailure(RemoteDataModelLogger::LogCommandAsJSON(path, data)); error = DataModelLogger::LogCommand(path, data); if (CHIP_NO_ERROR != error) @@ -97,7 +97,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub virtual void OnError(const chip::app::CommandSender * client, CHIP_ERROR error) override { - ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(error)); + LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(error)); ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(error)); mError = error; diff --git a/examples/chip-tool/commands/clusters/ReportCommand.h b/examples/chip-tool/commands/clusters/ReportCommand.h index f7e1993e26b70b..e90fb5ddf28f14 100644 --- a/examples/chip-tool/commands/clusters/ReportCommand.h +++ b/examples/chip-tool/commands/clusters/ReportCommand.h @@ -37,7 +37,7 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi CHIP_ERROR error = status.ToChipError(); if (CHIP_NO_ERROR != error) { - ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); + LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error)); mError = error; @@ -51,7 +51,7 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi return; } - ReturnOnFailure(RemoteDataModelLogger::LogAttributeAsJSON(path, data)); + LogErrorOnFailure(RemoteDataModelLogger::LogAttributeAsJSON(path, data)); error = DataModelLogger::LogAttribute(path, data); if (CHIP_NO_ERROR != error) @@ -70,7 +70,7 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi CHIP_ERROR error = status->ToChipError(); if (CHIP_NO_ERROR != error) { - ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(eventHeader, *status)); + LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(eventHeader, *status)); ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error)); mError = error; @@ -85,7 +85,7 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi return; } - ReturnOnFailure(RemoteDataModelLogger::LogEventAsJSON(eventHeader, data)); + LogErrorOnFailure(RemoteDataModelLogger::LogEventAsJSON(eventHeader, data)); CHIP_ERROR error = DataModelLogger::LogEvent(eventHeader, data); if (CHIP_NO_ERROR != error) @@ -98,6 +98,8 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi void OnError(CHIP_ERROR error) override { + LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(error)); + ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(error)); mError = error; } diff --git a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h index c3cea8783dbdd0..46a0b3dc4b37dd 100644 --- a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h +++ b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h @@ -120,7 +120,7 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi CHIP_ERROR error = status.ToChipError(); if (CHIP_NO_ERROR != error) { - ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); + LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); ChipLogError(chipTool, "Response Failure: %s", chip::ErrorStr(error)); mError = error; @@ -129,7 +129,7 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi void OnError(const chip::app::WriteClient * client, CHIP_ERROR error) override { - ReturnOnFailure(RemoteDataModelLogger::LogErrorAsJSON(error)); + LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(error)); ChipLogProgress(chipTool, "Error: %s", chip::ErrorStr(error)); mError = error;