feat: improve timeline/admin flows and ingest projection repairs

This commit is contained in:
2026-03-01 00:21:31 +03:00
parent c805daabcf
commit 229db81229
26 changed files with 2873 additions and 270 deletions

View File

@@ -7,6 +7,7 @@ import (
"net/http"
"regexp"
"runtime"
"runtime/debug"
"strconv"
"strings"
"time"
@@ -68,16 +69,35 @@ func writeJSON(w http.ResponseWriter, status int, payload any) {
}
}
func writeError(w http.ResponseWriter, status int, message string) {
func writeError(w http.ResponseWriter, status int, message string, cause ...error) {
if pc, file, line, ok := runtime.Caller(1); ok {
fn := runtime.FuncForPC(pc)
fnName := ""
if fn != nil {
fnName = fn.Name()
}
log.Printf("api error status=%d message=%q caller=%s:%d func=%s", status, message, file, line, fnName)
if status >= http.StatusInternalServerError {
root := "<nil>"
if len(cause) > 0 && cause[0] != nil {
root = cause[0].Error()
}
log.Printf(
"api error status=%d message=%q cause=%q caller=%s:%d func=%s\nstack=%s",
status, message, root, file, line, fnName, strings.TrimSpace(string(debug.Stack())),
)
} else {
log.Printf("api error status=%d message=%q caller=%s:%d func=%s", status, message, file, line, fnName)
}
} else {
log.Printf("api error status=%d message=%q", status, message)
if status >= http.StatusInternalServerError {
root := "<nil>"
if len(cause) > 0 && cause[0] != nil {
root = cause[0].Error()
}
log.Printf("api error status=%d message=%q cause=%q\nstack=%s", status, message, root, strings.TrimSpace(string(debug.Stack())))
} else {
log.Printf("api error status=%d message=%q", status, message)
}
}
writeJSON(w, status, map[string]string{"error": message})
}