Skip to content

Commit

Permalink
[chip-tool] The error is not reported over websocket when a read/subs…
Browse files Browse the repository at this point in the history
…cribe action has a global error (#27040)
  • Loading branch information
vivien-apple authored Jun 16, 2023
1 parent 90f4f7c commit 3be88f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions examples/chip-tool/commands/clusters/ClusterCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/chip-tool/commands/clusters/WriteAttributeCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 3be88f8

Please sign in to comment.