Skip to content

Commit c98873a

Browse files
author
tmayer
committed
Avoid catching exceptions other than NumberFormatException
1 parent c8133d2 commit c98873a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,20 @@ public void checkLeadinZero() throws ParseException {
138138

139139
protected Number extractFloat() throws ParseException {
140140
if (!acceptLeadinZero)
141-
checkLeadinZero();
142-
143-
try {
144-
if (!useHiPrecisionFloat)
141+
checkLeadinZero();
142+
143+
try {
144+
if (!useHiPrecisionFloat)
145145
return Float.parseFloat(xs);
146-
147-
if (xs.length() > 18) // follow JSonIJ parsing method
146+
147+
if (xs.length() > 18) // follow JSonIJ parsing method
148148
return new BigDecimal(xs);
149149

150-
return Double.parseDouble(xs);
150+
return Double.parseDouble(xs);
151151

152-
} catch(Exception e){
153-
throw new ParseException(pos, ERROR_UNEXPECTED_TOKEN, xs);
154-
}
152+
} catch(NumberFormatException e){
153+
throw new ParseException(pos, ERROR_UNEXPECTED_TOKEN, xs);
154+
}
155155
}
156156

157157
/**

0 commit comments

Comments
 (0)