MCPcopy
hub / github.com/autobrr/qui / writeJSONError

Function writeJSONError

internal/proxy/handler.go:615–626  ·  view source on GitHub ↗
(w http.ResponseWriter, status int, message string)

Source from the content-addressed store, hash-verified

613}
614
615func writeJSONError(w http.ResponseWriter, status int, message string) {
616 w.Header().Set("Content-Type", "application/json")
617 w.WriteHeader(status)
618
619 err := json.NewEncoder(w).Encode(map[string]string{"error": message})
620 if err != nil {
621 log.Error().Err(err).Int("status", status).Msg("Failed to encode JSON error response")
622 if _, writeErr := io.WriteString(w, "error\n"); writeErr != nil {
623 log.Error().Err(writeErr).Int("status", status).Msg("Failed to write JSON error fallback response")
624 }
625 }
626}
627
628type proxyMediaInfoRequestError struct {
629 status int

Callers 1

Calls 4

SetMethod · 0.45
HeaderMethod · 0.45
WriteHeaderMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected