Skip to content

Commit 196abfe

Browse files
committed
ListTool: Handle ParsingException
1 parent 97bbedc commit 196abfe

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/org/netpreserve/jwarc/tools/ListTool.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,25 @@ public static void main(String[] args) throws IOException {
1515
url = ((WarcTargetRecord) record).target();
1616
}
1717

18+
Exception exception = null;
1819
String methodOrStatus = "-";
1920
if (record.contentType().base().equals(MediaType.HTTP)) {
20-
if (record instanceof WarcRequest) {
21-
methodOrStatus = ((WarcRequest) record).http().method();
22-
} else if (record instanceof WarcResponse) {
23-
methodOrStatus = String.valueOf(((WarcResponse) record).http().status());
21+
try {
22+
if (record instanceof WarcRequest) {
23+
methodOrStatus = ((WarcRequest) record).http().method();
24+
} else if (record instanceof WarcResponse) {
25+
methodOrStatus = String.valueOf(((WarcResponse) record).http().status());
26+
}
27+
} catch (ParsingException e) {
28+
methodOrStatus = "invalid";
29+
exception = e;
2430
}
2531
}
2632

2733
System.out.format("%10d %-10s %-4s %s\n", reader.position(), record.type(), methodOrStatus, url);
34+
if (exception != null) {
35+
System.err.println(exception.getMessage());
36+
}
2837
}
2938
}
3039
}

0 commit comments

Comments
 (0)