MCPcopy
hub / github.com/dgraph-io/dgraph / SetStatus

Function SetStatus

x/x.go:350–363  ·  view source on GitHub ↗

SetStatus sets the error code, message and the newly assigned uids in the http response.

(w http.ResponseWriter, code, msg string)

Source from the content-addressed store, hash-verified

348// SetStatus sets the error code, message and the newly assigned uids
349// in the http response.
350func SetStatus(w http.ResponseWriter, code, msg string) {
351 w.Header().Set("Content-Type", "application/json")
352 var qr queryRes
353 ext := make(map[string]interface{})
354 ext["code"] = code
355 qr.Errors = append(qr.Errors, &GqlError{Message: msg, Extensions: ext})
356 if js, err := json.Marshal(qr); err == nil {
357 if _, err := w.Write(js); err != nil {
358 glog.Errorf("Could not send error msg=%+v code=%+v due to http error %+v", msg, code, err)
359 }
360 } else {
361 Panic(errors.Errorf("Unable to marshal: %+v", qr))
362 }
363}
364
365func SetStatusWithErrors(w http.ResponseWriter, code string, errs []string) {
366 var qr queryRes

Callers 15

intFromQueryParamFunction · 0.92
assignMethod · 0.92
removeNodeMethod · 0.92
moveTabletMethod · 0.92
getStateMethod · 0.92
pingResponseMethod · 0.92
commonHandlerFunction · 0.92
readRequestFunction · 0.92
queryHandlerFunction · 0.92
mutationHandlerFunction · 0.92
commitHandlerFunction · 0.92
alterHandlerFunction · 0.92

Calls 4

PanicFunction · 0.85
SetMethod · 0.65
WriteMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected