Skip to content

Commit

Permalink
Need better error output when chip-tool struct members are not quoted. (
Browse files Browse the repository at this point in the history
#14906)

chip-tool expects struct member names in double-quotes. When that does
not happen, it does not make it clear that's what it expects.

Adjust the error message to say what needs to happen.
  • Loading branch information
bzbarsky-apple authored Feb 8, 2022
1 parent 64d3ad7 commit 9ae2a63
Show file tree
Hide file tree
Showing 3 changed files with 335 additions and 251 deletions.
4 changes: 2 additions & 2 deletions examples/chip-tool/commands/clusters/ComplexArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,14 @@ class ComplexArgumentParser
return CHIP_NO_ERROR;
}

static CHIP_ERROR EnsureMemberExist(const char * label, bool hasMember)
static CHIP_ERROR EnsureMemberExist(const char * label, const char * memberName, bool hasMember)
{
if (hasMember)
{
return CHIP_NO_ERROR;
}

ChipLogError(chipTool, "%s is required.", label);
ChipLogError(chipTool, "%s is required. Should be provided as {\"%s\": value}", label, memberName);
return CHIP_ERROR_INVALID_ARGUMENT;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, {{zapTypeToEncodable

{{#zcl_struct_items}}
{{#unless isOptional}}
ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("{{parent.name}}.{{asLowerCamelCase label}}", value.isMember("{{asLowerCamelCase label}}")));
ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("{{parent.name}}.{{asLowerCamelCase label}}", "{{asLowerCamelCase label}}", value.isMember("{{asLowerCamelCase label}}")));
{{/unless}}
{{/zcl_struct_items}}

Expand Down
Loading

0 comments on commit 9ae2a63

Please sign in to comment.