Skip to content

Commit 358baba

Browse files
committed
Use JsonParser in JsonParseExceptionBuilder
1 parent 9746bbf commit 358baba

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/com/github/fge/jackson/JsonNodeReader.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,9 @@ public JsonNode fromReader(final Reader r)
133133
private static JsonNode readNode(final MappingIterator<JsonNode> iterator)
134134
throws IOException
135135
{
136-
final Object source = iterator.getParser().getInputSource();
136+
final JsonParser parser = iterator.getParser();
137137
final JsonParseExceptionBuilder builder
138-
= new JsonParseExceptionBuilder(source);
138+
= new JsonParseExceptionBuilder(parser);
139139

140140
builder.setMessage(BUNDLE.getMessage("read.noContent"));
141141

@@ -160,13 +160,15 @@ private static JsonNode readNode(final MappingIterator<JsonNode> iterator)
160160
private static final class JsonParseExceptionBuilder
161161
implements Builder<JsonParseException>
162162
{
163+
private JsonParser parser;
163164
private String message = "";
164165
private JsonLocation location;
165166

166-
private JsonParseExceptionBuilder(@Nonnull final Object source)
167+
private JsonParseExceptionBuilder(@Nonnull final JsonParser parser)
167168
{
168-
BUNDLE.checkNotNull(source, "read.nullArgument");
169-
location = new JsonLocation(source, 0L, 1, 1);
169+
BUNDLE.checkNotNull(parser, "read.nullArgument");
170+
this.parser = parser;
171+
location = parser.getCurrentLocation();
170172
}
171173

172174
private JsonParseExceptionBuilder setMessage(
@@ -186,7 +188,7 @@ private JsonParseExceptionBuilder setLocation(
186188
@Override
187189
public JsonParseException build()
188190
{
189-
return new JsonParseException(message, location);
191+
return new JsonParseException(parser, message, location);
190192
}
191193
}
192194
}

0 commit comments

Comments
 (0)