@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()); }
private static int getErrorOffset(final JsonReader reader) { return reader != null ? reader.getPosition() - 1 : -1; }
DecodeException extends ParseException { private static int getErrorOffset(final JsonReader reader) { return reader != null ? reader.getPosition() - 1 : -1; } }
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); }
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(); }
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();  }