Skip to content

Detect and throw on invalid integer.

Lukasa requested to merge lukasa/RediStack:cb-parse-integer-master into master

Motivation:

parseInteger did not distinguish between not having enough bytes for an integer and not being able to parse the integer that was present. This was a bit tricky for code internally, where some call sites had extra code looking for spooky action at a distance in order to determine if the integer failed to parse.

This is unnecessary: parseInteger is sufficiently aware of what's going on to address this problem itself.

Modifications:

  • Added a new parser error (acceptable as we haven't tagged 1.0 yet).
  • Throw it from parseInteger if the integer is invalid.

Result:

parseInteger clearly communicates if the integer failed to parse.

Merge request reports