Skip to content

Commit 67c2ae4

Browse files
joerg1985LogicOscar
authored andcommitted
[java] make the json parsing exception text more helpful
1 parent e2ae81e commit 67c2ae4

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

java/src/org/openqa/selenium/json/Input.java

+15-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,21 @@ public String toString() {
9797
length = MEMORY_SIZE;
9898
}
9999

100-
return "Last " + length + " characters read: " + new String(buffer, offset, length);
100+
String last = "Last " + length + " characters read: " + new String(buffer, offset, length);
101+
int next = Math.min(MEMORY_SIZE, filled - (offset + length));
102+
103+
if (next > 0) {
104+
if (next > 128) {
105+
next = 128;
106+
}
107+
return last
108+
+ ", next "
109+
+ next
110+
+ " characters to read: "
111+
+ new String(buffer, offset + length, next);
112+
}
113+
114+
return last;
101115
}
102116

103117
/**

0 commit comments

Comments
 (0)