MCPcopy Create free account
hub / github.com/PostHog/duckgres / WriteErrorResponse

Function WriteErrorResponse

server/wire/protocol.go:246–270  ·  view source on GitHub ↗

writeErrorResponse sends an error to the client

(w io.Writer, severity, code, message string)

Source from the content-addressed store, hash-verified

244}
245
246// writeBackendKeyData sends the backend key data (for cancel requests)
247func WriteBackendKeyData(w io.Writer, pid, secretKey int32) error {
248 data := make([]byte, 8)
249 binary.BigEndian.PutUint32(data[:4], uint32(pid))
250 binary.BigEndian.PutUint32(data[4:], uint32(secretKey))
251 return WriteMessage(w, MsgBackendKeyData, data)
252}
253
254// writeReadyForQuery indicates the server is ready for a new query
255func WriteReadyForQuery(w io.Writer, txStatus byte) error {
256 return WriteMessage(w, MsgReadyForQuery, []byte{txStatus})
257}
258
259// writeErrorResponse sends an error to the client
260func WriteErrorResponse(w io.Writer, severity, code, message string) error {
261 message = RedactSecrets(message)
262
263 var data []byte
264
265 // Severity
266 data = append(data, 'S')
267 data = append(data, []byte(severity)...)
268 data = append(data, 0)
269
270 // SQLSTATE code
271 data = append(data, 'C')
272 data = append(data, []byte(code)...)
273 data = append(data, 0)

Callers 6

TestWriteErrorResponseFunction · 0.92
sendErrorMethod · 0.92
authenticateChildClientFunction · 0.92
runChildWorkerFunction · 0.92
WriteErrorResponseFunction · 0.92

Calls 2

RedactSecretsFunction · 0.85
WriteMessageFunction · 0.85

Tested by 2

TestWriteErrorResponseFunction · 0.74