From 2d2a8d9c89bba9548a15af59fedf80fd84e70d0b Mon Sep 17 00:00:00 2001 From: Florian Reiterer Date: Tue, 26 Jan 2016 09:36:15 +0100 Subject: [PATCH] Better grpc error strings Closes #87 --- runtime/errors.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/errors.go b/runtime/errors.go index 3525e2c6a01..98c1950d4de 100644 --- a/runtime/errors.go +++ b/runtime/errors.go @@ -64,6 +64,7 @@ var ( type errorBody struct { Error string `json:"error"` + Code int `json:"code"` } // DefaultHTTPError is the default implementation of HTTPError. @@ -76,7 +77,7 @@ func DefaultHTTPError(ctx context.Context, w http.ResponseWriter, _ *http.Reques const fallback = `{"error": "failed to marshal error message"}` w.Header().Set("Content-Type", "application/json") - body := errorBody{Error: err.Error()} + body := errorBody{Error: grpc.ErrorDesc(err), Code: int(grpc.Code(err))} buf, merr := json.Marshal(body) if merr != nil { glog.Errorf("Failed to marshal error message %q: %v", body, merr)