pratapaditya04 commented on PR #4057:
URL: https://github.com/apache/gobblin/pull/4057#issuecomment-2357539654
> @pratapaditya04 this is the default implementation of LONG_OR_DOUBLE enum
policy present in the library
>
> ```
> LONG_OR_DOUBLE {
> @Override public Number readNumber(JsonReader in) throws IOException,
JsonParseException {
> String value = in.nextString();
> try {
> return Long.parseLong(value);
> } catch (NumberFormatException longE) {
> try {
> Double d = Double.valueOf(value);
> if ((d.isInfinite() || d.isNaN()) && !in.isLenient()) {
> throw new MalformedJsonException("JSON forbids NaN and
infinities: " + d + "; at path " + in.getPath());
> }
> return d;
> } catch (NumberFormatException doubleE) {
> throw new JsonParseException("Cannot parse " + value + "; at path
" + in.getPath(), doubleE);
> }
> }
> }
> },
> ```
>
> I have tried to just add one more layer on top to parse Int that's why
exception and naming i have kept similar to library implementation
Hmmm, but still 3 layers of nesting impacts readability a lot, so breaking
down into smaller functions can be a possible alternative,but leaving it upto
you on how to handle it. Also naming exception variables var3, var2, doesn't
seem right.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]