Use better error message when parsing incomplete JSON.

When input is exhausted during parsing, we currently rely on the JVM's
bounds-checking, and wrap its IndexOutOfBoundsException in a Failure.
This commit will instead throw a custom exception which makes it
clear that the problem is with the input.