Skip to content

Report missing keys#26

Open
hlounent wants to merge 2 commits intono1msd:masterfrom
hlounent:report-missing-keys
Open

Report missing keys#26
hlounent wants to merge 2 commits intono1msd:masterfrom
hlounent:report-missing-keys

Conversation

@hlounent
Copy link
Copy Markdown

@hlounent hlounent commented Apr 10, 2019

Add support for throwing an exception if a key referenced by a template is not found. This is useful for clients that want to ensure templates and the related input data structure match and want to handle potential mismatches as failures.

P.S. I also rebased the patches against torbjoernk/mstch branch develop and pushed to the branch torbjoernk/report-missing-keys as some of the other open pull requests have been merged there.

Hannu Lounento added 2 commits April 9, 2019 15:17
The new test case verifies the current behavior that no exceptions are
thrown if a key mentioned in a template is not found.

The Catch2 TEST_CASE macro was used directly instead of the MSTCH_TEST
or other macros because this test case does not verify output of the
mstch::render with a given input, what MSTCH_TEST and friends are for.

Signed-off-by: Hannu Lounento <hannu.lounento@vaisala.com>
Throwing an exception enables clients to detect failures to render
template completely due to missing keys. This is useful in cases where
clients expect templates and the data structure to always match and
treat missing keys as failures.

Define a custom exception to enable clients to identify the specific
type of the error.

Signed-off-by: Hannu Lounento <hannu.lounento@vaisala.com>
@danobi
Copy link
Copy Markdown

danobi commented May 7, 2019

Ignoring the code (although it looks fine to me), I'm +1 on this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants