Skip to content

Commit 7a6046b

Browse files
committed
Add faketime format exception
Signed-off-by: Aaron Lew <[email protected]>
1 parent 8aee2f6 commit 7a6046b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tuf-cli/src/main/java/dev/sigstore/tuf/cli/TufConformanceServer.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,16 @@ private static void handleExecute(HttpServletRequest request, HttpServletRespons
9595
System.setErr(errPs);
9696
}
9797

98-
Instant fakeNow = Instant.ofEpochSecond(Long.parseLong(executeRequest.faketime));
99-
TestClock.set(Clock.fixed(fakeNow, ZoneOffset.UTC));
98+
try {
99+
Instant fakeNow = Instant.ofEpochSecond(Long.parseLong(executeRequest.faketime));
100+
TestClock.set(Clock.fixed(fakeNow, ZoneOffset.UTC));
101+
} catch (NumberFormatException e) {
102+
throw new IllegalArgumentException(
103+
"Invalid 'faketime' format. Must be a long representing epoch seconds, but was: '"
104+
+ executeRequest.faketime
105+
+ "'",
106+
e);
107+
}
100108

101109
List<String> resolvedArgs = new java.util.ArrayList<>();
102110
resolvedArgs.addAll(Arrays.asList(executeRequest.args));

0 commit comments

Comments
 (0)