MCPcopy
hub / github.com/modelcontextprotocol/registry / writeErrorResponse

Function writeErrorResponse

internal/api/server.go:46–56  ·  view source on GitHub ↗

writeErrorResponse writes a JSON error response using huma's ErrorModel format for consistency with the rest of the API.

(w http.ResponseWriter, status int, detail string)

Source from the content-addressed store, hash-verified

44// writeErrorResponse writes a JSON error response using huma's ErrorModel format
45// for consistency with the rest of the API.
46func writeErrorResponse(w http.ResponseWriter, status int, detail string) {
47 w.Header().Set("Content-Type", "application/json")
48 w.WriteHeader(status)
49
50 errModel := &huma.ErrorModel{
51 Title: http.StatusText(status),
52 Status: status,
53 Detail: detail,
54 }
55 _ = json.NewEncoder(w).Encode(errModel)
56}
57
58// containsNulByte checks if a string contains a NUL byte, either as a literal \x00
59// or URL-encoded as %00.

Callers 1

Calls 1

SetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…