Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(461)

Side by Side Diff: grpc/prpc/encoding.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: copyright Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package prpc 5 package prpc
6 6
7 // This file implements encoding of RPC results to HTTP responses. 7 // This file implements encoding of RPC results to HTTP responses.
8 8
9 import ( 9 import (
10 "bytes" 10 "bytes"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 _, err = buf.WriteRune('\n') 81 _, err = buf.WriteRune('\n')
82 } 82 }
83 res.body = buf.Bytes() 83 res.body = buf.Bytes()
84 84
85 case FormatText: 85 case FormatText:
86 var buf bytes.Buffer 86 var buf bytes.Buffer
87 err = proto.MarshalText(&buf, msg) 87 err = proto.MarshalText(&buf, msg)
88 res.body = buf.Bytes() 88 res.body = buf.Bytes()
89 89
90 default: 90 default:
91 » » panic(fmt.Errorf("impossible: invalid format %s", format)) 91 » » panic(fmt.Errorf("impossible: invalid format %d", format))
92 92
93 } 93 }
94 if err != nil { 94 if err != nil {
95 return errResponse(codes.Internal, 0, escapeFmt(err.Error())) 95 return errResponse(codes.Internal, 0, escapeFmt(err.Error()))
96 } 96 }
97 97
98 return &res 98 return &res
99 } 99 }
100 100
101 // respondProtocolError creates a response for a pRPC protocol error. 101 // respondProtocolError creates a response for a pRPC protocol error.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 138 }
139 139
140 // codeStatus maps gRPC codes to HTTP status codes. 140 // codeStatus maps gRPC codes to HTTP status codes.
141 // Falls back to http.StatusInternalServerError. 141 // Falls back to http.StatusInternalServerError.
142 func codeStatus(code codes.Code) int { 142 func codeStatus(code codes.Code) int {
143 if status, ok := codeToStatus[code]; ok { 143 if status, ok := codeToStatus[code]; ok {
144 return status 144 return status
145 } 145 }
146 return http.StatusInternalServerError 146 return http.StatusInternalServerError
147 } 147 }
OLDNEW
« grpc/grpcutil/errors.go ('K') | « grpc/prpc/client_test.go ('k') | grpc/prpc/server.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698