Improve diagnostics when extracting a non-existent subsection

Closes gh-568
This commit is contained in:
Andy Wilkinson
2019-08-30 14:05:50 +01:00
parent 1727b4e3c8
commit 1b87af13be
2 changed files with 12 additions and 0 deletions

View File

@@ -75,6 +75,9 @@ public class FieldPathPayloadSubsectionExtractor
ExtractedField extractedField = new JsonFieldProcessor().extract(this.fieldPath,
objectMapper.readValue(payload, Object.class));
Object value = extractedField.getValue();
if (value == ExtractedField.ABSENT) {
throw new PayloadHandlingException(this.fieldPath + " does not identify a section of the payload");
}
if (value instanceof List) {
List<?> extractedList = (List<?>) value;
Set<String> uncommonPaths = JsonFieldPaths.from(extractedList).getUncommon();