Result box: color-code by status + friendly error messages from error codes (#105)
CI / test (push) Successful in 23s
CI / docker (push) Skipped

- Backend create/can validation paths emit machine-readable error codes
  (slug_taken, slug_invalid, content_empty, content_too_large,
  expiry_invalid, rate_limited, ...) alongside the human message
- new.html JS maps codes to plain-language guidance with generic fallback
- Result card colored via --ok/--err/--warn left border (result-ok/err/warn)
- docs/API.md error section documents the code field
- Tests assert the code on every validation path
This commit is contained in:
2026-09-09 17:28:25 -05:00
parent c35531e03e
commit 9df6224a27
7 changed files with 216 additions and 18 deletions
+1 -1
View File
@@ -113,7 +113,7 @@ func rateLimitAdmin(r *http.Request) bool {
// writeRateLimited responds 429 with Retry-After based on refill rate.
func writeRateLimited(w http.ResponseWriter, retryAfterSecs int) {
w.Header().Set("Retry-After", strconv.Itoa(retryAfterSecs))
writeErr(w, 429, "rate limit exceeded")
writeErrCode(w, 429, "rate_limited", "rate limit exceeded")
}
// setRateLimitHeaders sets informational X-RateLimit headers for create/guess.