@@ -272,7 +272,7 @@ Status CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommandElem
272
272
ChipLogDetail (DataManagement, " No command " ChipLogFormatMEI " in Cluster " ChipLogFormatMEI " on Endpoint 0x%x" ,
273
273
ChipLogValueMEI (concretePath.mCommandId ), ChipLogValueMEI (concretePath.mClusterId ),
274
274
concretePath.mEndpointId );
275
- return FallibleAddStatus (concretePath, commandExists) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
275
+ return AddStatus (concretePath, commandExists) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
276
276
}
277
277
}
278
278
@@ -287,18 +287,18 @@ Status CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommandElem
287
287
{
288
288
if (err != CHIP_ERROR_ACCESS_DENIED)
289
289
{
290
- return FallibleAddStatus (concretePath, Status::Failure) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
290
+ return AddStatus (concretePath, Status::Failure) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
291
291
}
292
292
// TODO: when wildcard invokes are supported, handle them to discard rather than fail with status
293
- return FallibleAddStatus (concretePath, Status::UnsupportedAccess) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
293
+ return AddStatus (concretePath, Status::UnsupportedAccess) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
294
294
}
295
295
}
296
296
297
297
if (CommandNeedsTimedInvoke (concretePath.mClusterId , concretePath.mCommandId ) && !IsTimedInvoke ())
298
298
{
299
299
// TODO: when wildcard invokes are supported, discard a
300
300
// wildcard-expanded path instead of returning a status.
301
- return FallibleAddStatus (concretePath, Status::NeedsTimedInteraction) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
301
+ return AddStatus (concretePath, Status::NeedsTimedInteraction) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
302
302
}
303
303
304
304
if (CommandIsFabricScoped (concretePath.mClusterId , concretePath.mCommandId ))
@@ -312,7 +312,7 @@ Status CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommandElem
312
312
{
313
313
// TODO: when wildcard invokes are supported, discard a
314
314
// wildcard-expanded path instead of returning a status.
315
- return FallibleAddStatus (concretePath, Status::UnsupportedAccess) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
315
+ return AddStatus (concretePath, Status::UnsupportedAccess) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
316
316
}
317
317
}
318
318
@@ -337,7 +337,7 @@ Status CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommandElem
337
337
exit :
338
338
if (err != CHIP_NO_ERROR)
339
339
{
340
- return FallibleAddStatus (concretePath, Status::InvalidCommand) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
340
+ return AddStatus (concretePath, Status::InvalidCommand) != CHIP_NO_ERROR ? Status::Failure : Status::Success;
341
341
}
342
342
343
343
// We have handled the error status above and put the error status in response, now return success status so we can process
@@ -468,31 +468,31 @@ CHIP_ERROR CommandHandler::AddStatusInternal(const ConcreteCommandPath & aComman
468
468
return FinishStatus ();
469
469
}
470
470
471
- void CommandHandler::AddStatus (const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus,
472
- const char * context)
471
+ CHIP_ERROR CommandHandler::AddStatus (const ConcreteCommandPath & aCommandPath, const Status aStatus)
473
472
{
474
-
475
- VerifyOrDie (FallibleAddStatus (aCommandPath, aStatus, context) == CHIP_NO_ERROR);
473
+ return AddStatusInternal (aCommandPath, StatusIB (aStatus));
476
474
}
477
475
478
- CHIP_ERROR CommandHandler::FallibleAddStatus (const ConcreteCommandPath & path, const Protocols::InteractionModel::Status status,
479
- const char * context)
476
+ void CommandHandler::AddStatusAndLogIfFailure (const ConcreteCommandPath & aCommandPath, const Status aStatus, const char * aMessage)
480
477
{
481
-
482
- if (status != Status::Success)
478
+ if (aStatus != Status::Success)
483
479
{
484
- if (context == nullptr )
485
- {
486
- context = " no additional context" ;
487
- }
488
-
489
480
ChipLogError (DataManagement,
490
- " Endpoint=%u Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI " status " ChipLogFormatIMStatus " (%s)" ,
491
- path.mEndpointId , ChipLogValueMEI (path.mClusterId ), ChipLogValueMEI (path.mCommandId ),
492
- ChipLogValueIMStatus (status), context);
481
+ " Failed to handle on Endpoint=%u Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI
482
+ " with " ChipLogFormatIMStatus " : %s" ,
483
+ aCommandPath.mEndpointId , ChipLogValueMEI (aCommandPath.mClusterId ), ChipLogValueMEI (aCommandPath.mCommandId ),
484
+ ChipLogValueIMStatus (aStatus), aMessage);
493
485
}
494
486
495
- return AddStatusInternal (path, StatusIB (status));
487
+ CHIP_ERROR err = AddStatus (aCommandPath, aStatus);
488
+ if (err != CHIP_NO_ERROR)
489
+ {
490
+ ChipLogError (DataManagement,
491
+ " Failed to set status on Endpoint=%u Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI
492
+ " : %" CHIP_ERROR_FORMAT,
493
+ aCommandPath.mEndpointId , ChipLogValueMEI (aCommandPath.mClusterId ), ChipLogValueMEI (aCommandPath.mCommandId ),
494
+ err.Format ());
495
+ }
496
496
}
497
497
498
498
CHIP_ERROR CommandHandler::AddClusterSpecificSuccess (const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus)
0 commit comments