MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / SetStatusWithErrors

Function SetStatusWithErrors

x/x.go:365–379  ·  view source on GitHub ↗
(w http.ResponseWriter, code string, errs []string)

Source from the content-addressed store, hash-verified

363}
364
365func SetStatusWithErrors(w http.ResponseWriter, code string, errs []string) {
366 var qr queryRes
367 ext := make(map[string]interface{})
368 ext["code"] = code
369 for _, err := range errs {
370 qr.Errors = append(qr.Errors, &GqlError{Message: err, Extensions: ext})
371 }
372 if js, err := json.Marshal(qr); err == nil {
373 if _, err := w.Write(js); err != nil {
374 glog.Errorf("Error while writing: %+v", err)
375 }
376 } else {
377 Panic(errors.Errorf("Unable to marshal: %+v", qr))
378 }
379}
380
381// SetHttpStatus is similar to SetStatus but sets a proper HTTP status code
382// in the response instead of always returning HTTP 200 (OK).

Callers 1

schemaValidateHandlerFunction · 0.92

Calls 3

PanicFunction · 0.85
WriteMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected