Skip to content

Commit

Permalink
Better grpc error strings
Browse files Browse the repository at this point in the history
Closes #87
  • Loading branch information
Florian Reiterer committed Jan 26, 2016
1 parent dd0938e commit 2d2a8d9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion runtime/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var (

type errorBody struct {
Error string `json:"error"`
Code int `json:"code"`
}

// DefaultHTTPError is the default implementation of HTTPError.
Expand All @@ -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)
Expand Down

0 comments on commit 2d2a8d9

Please sign in to comment.