Include calling function in error message

Entire-Checkpoint: a4948d0fe7a3
This commit is contained in:
2026-03-16 15:42:38 +01:00
parent bab6eb4c3a
commit 7f3eb443d9

View File

@@ -16,6 +16,7 @@ import (
"net/http"
"os"
"path/filepath"
"runtime"
"strings"
"sync"
@@ -184,7 +185,8 @@ type DefaultAPIResponse struct {
// handleError writes a standardized JSON error response with the given status code.
// It logs the error at WARN level and ensures proper Content-Type headers are set.
func handleError(err error, statusCode int, rw http.ResponseWriter) {
cclog.Warnf("REST ERROR : %s", err.Error())
_, file, line, _ := runtime.Caller(1)
cclog.Warnf("REST ERROR (%s:%d): %s", filepath.Base(file), line, err.Error())
rw.Header().Add("Content-Type", "application/json")
rw.WriteHeader(statusCode)
if err := json.NewEncoder(rw).Encode(ErrorResponse{