Skip to content

Commit 40ec548

Browse files
committed
improve error message
1 parent 1073c84 commit 40ec548

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/main/java/com/jsoniter/IterImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ public static Any readAny(JsonIterator iter) throws IOException {
174174
case '8':
175175
case '9':
176176
skipUntilBreak(iter);
177+
// TODO: LongLazyAny or DoubleLazyAny
177178
return Any.lazyNumber(iter.buf, start, iter.head);
178179
case 't':
179180
skipUntilBreak(iter);

src/main/java/com/jsoniter/IterImplNumber.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ private static final double readNegativeDouble(JsonIterator iter, int start) thr
107107
}
108108

109109
public static final double readDoubleSlowPath(JsonIterator iter) throws IOException {
110-
return Double.valueOf(readNumber(iter));
110+
try {
111+
return Double.valueOf(readNumber(iter));
112+
} catch (NumberFormatException e) {
113+
throw iter.reportError("readDoubleSlowPath", e.toString());
114+
}
111115
}
112116

113117
public static final float readFloat(JsonIterator iter) throws IOException {
@@ -196,7 +200,11 @@ private static final float readNegativeFloat(JsonIterator iter, int start) throw
196200
}
197201

198202
public static final float readFloatSlowPath(JsonIterator iter) throws IOException {
199-
return Float.valueOf(readNumber(iter));
203+
try {
204+
return Float.valueOf(readNumber(iter));
205+
} catch (NumberFormatException e) {
206+
throw iter.reportError("readDoubleSlowPath", e.toString());
207+
}
200208
}
201209

202210
public static final String readNumber(JsonIterator iter) throws IOException {

src/test/java/com/jsoniter/TestObject.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.jsoniter;
22

3+
import com.jsoniter.annotation.JsoniterAnnotationSupport;
34
import com.jsoniter.any.Any;
45
import com.jsoniter.spi.EmptyExtension;
56
import com.jsoniter.spi.JsoniterSpi;

0 commit comments

Comments
 (0)