### Question:
DecodeException extends ParseException { private static int getErrorOffset(final JsonReader reader) { return reader != null ? reader.getPosition() - 1 : -1; } DecodeException(final Error error);  DecodeException(final String message, final JsonReader reader);  DecodeException(final String message, final JsonReader reader, final Throwable cause); JsonReader getReader(); String getContent();  }### Answer:
@Test public void testMessageOffset() { final String message = "hello world"; final int offset = 37; final JsonReader reader = new JsonReader(new StringReader(message)) { @Override public int getPosition() { return offset + 1; } }; final DecodeException e = new DecodeException(message, reader); assertTrue(e.getMessage().startsWith(message)); assertEquals(offset, e.getErrorOffset()); }
@Test public void testMessageOffsetCause() { final Exception cause = new NullPointerException(); final DecodeException e = new DecodeException(message, reader, cause); assertTrue(e.getMessage().startsWith(message)); assertEquals(offset, e.getErrorOffset()); assertEquals(cause, e.getCause()); }