Add clock drift error messages to remaining 18 implementations
When timestamp auth fails (401 with timestamp in error), show helpful message: - Error: Request timestamp expired (must be within 5 minutes of server time) - Your computer's clock may have drifted. - NTP sync commands for Linux/macOS/Windows Updated: Un.cs, Un.java, un.clj, un.cob, un.erl, un.ex, un.f90, un.forth, un.fs, un.hs, un.lisp, un.m, un.ml, un.pro, un.r, un.raku, un.scm, un.zig All 42 implementations now have clock drift detection.
This commit is contained in:
parent
bc0da08a08
commit
a5a4f23594
18 changed files with 455 additions and 42 deletions
12
Un.java
12
Un.java
|
|
@ -555,6 +555,18 @@ public class Un {
|
|||
int status = conn.getResponseCode();
|
||||
if (status < 200 || status >= 300) {
|
||||
String error = readStream(conn.getErrorStream());
|
||||
|
||||
// Check for clock drift errors
|
||||
if (error.contains("timestamp") && (status == 401 || error.toLowerCase().contains("expired") || error.toLowerCase().contains("invalid"))) {
|
||||
System.err.println(RED + "Error: Request timestamp expired (must be within 5 minutes of server time)" + RESET);
|
||||
System.err.println(YELLOW + "Your computer's clock may have drifted." + RESET);
|
||||
System.err.println("Check your system time and sync with NTP if needed:");
|
||||
System.err.println(" Linux: sudo ntpdate -s time.nist.gov");
|
||||
System.err.println(" macOS: sudo sntp -sS time.apple.com");
|
||||
System.err.println(" Windows: w32tm /resync");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
throw new Exception("HTTP " + status + " - " + error);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue