Skip to content

Commit 71aefee

Browse files
5368-Lenient-error-handler-doesn't-always-include-location-information (hapifhir#6678)
* 5368---Lenient-error-handler-doesn't-always-include-location-information * Credit for hapifhir#6678 --------- Co-authored-by: James Agnew <[email protected]>
1 parent 1385edc commit 71aefee

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/LenientErrorHandler.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public LenientErrorHandler(boolean theLogErrors) {
7373
@Override
7474
public void containedResourceWithNoId(IParseLocation theLocation) {
7575
if (myLogErrors) {
76-
ourLog.warn("Resource has contained child resource with no ID");
76+
ourLog.warn("{}Resource has contained child resource with no ID", describeLocation(theLocation));
7777
}
7878
}
7979

@@ -87,8 +87,9 @@ public void incorrectJsonType(
8787
ScalarType theFoundScalarType) {
8888
if (myLogErrors) {
8989
if (ourLog.isWarnEnabled()) {
90-
String message = createIncorrectJsonTypeMessage(
91-
theElementName, theExpected, theExpectedScalarType, theFound, theFoundScalarType);
90+
String message = describeLocation(theLocation) +
91+
createIncorrectJsonTypeMessage(
92+
theElementName, theExpected, theExpectedScalarType, theFound, theFoundScalarType);
9293
ourLog.warn(message);
9394
}
9495
}
@@ -134,7 +135,7 @@ public boolean isErrorOnInvalidExtension() {
134135
@Override
135136
public void missingRequiredElement(IParseLocation theLocation, String theElementName) {
136137
if (myLogErrors) {
137-
ourLog.warn("Resource is missing required element: {}", theElementName);
138+
ourLog.warn("{}Resource is missing required element: {}", describeLocation(theLocation), theElementName);
138139
}
139140
}
140141

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
type: add
3+
issue: 5368
4+
title: "Several error messages reported by the LenientErrorHandler (the default parser error handler)
5+
did not include location information in their message. Thanks to Elliot Lavy for the contribution!"

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,11 @@
969969
<name>Mangala Ekanayake</name>
970970
<organization>Cambio</organization>
971971
</developer>
972+
<developer>
973+
<id>elavy-harris</id>
974+
<name>Eliott Lavy</name>
975+
<organization>Harris</organization>
976+
</developer>
972977
</developers>
973978

974979
<licenses>

0 commit comments

Comments
 (0)