mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
vendor: github.com/moby/buildkit db304eb93126 (v0.13.0-dev)
full diff: d6e142600e...db304eb931
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
28
vendor/google.golang.org/grpc/internal/status/status.go
generated
vendored
28
vendor/google.golang.org/grpc/internal/status/status.go
generated
vendored
@ -43,6 +43,34 @@ type Status struct {
|
||||
s *spb.Status
|
||||
}
|
||||
|
||||
// NewWithProto returns a new status including details from statusProto. This
|
||||
// is meant to be used by the gRPC library only.
|
||||
func NewWithProto(code codes.Code, message string, statusProto []string) *Status {
|
||||
if len(statusProto) != 1 {
|
||||
// No grpc-status-details bin header, or multiple; just ignore.
|
||||
return &Status{s: &spb.Status{Code: int32(code), Message: message}}
|
||||
}
|
||||
st := &spb.Status{}
|
||||
if err := proto.Unmarshal([]byte(statusProto[0]), st); err != nil {
|
||||
// Probably not a google.rpc.Status proto; do not provide details.
|
||||
return &Status{s: &spb.Status{Code: int32(code), Message: message}}
|
||||
}
|
||||
if st.Code == int32(code) {
|
||||
// The codes match between the grpc-status header and the
|
||||
// grpc-status-details-bin header; use the full details proto.
|
||||
return &Status{s: st}
|
||||
}
|
||||
return &Status{
|
||||
s: &spb.Status{
|
||||
Code: int32(codes.Internal),
|
||||
Message: fmt.Sprintf(
|
||||
"grpc-status-details-bin mismatch: grpc-status=%v, grpc-message=%q, grpc-status-details-bin=%+v",
|
||||
code, message, st,
|
||||
),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// New returns a Status representing c and msg.
|
||||
func New(c codes.Code, msg string) *Status {
|
||||
return &Status{s: &spb.Status{Code: int32(c), Message: msg}}
|
||||
|
Reference in New Issue
Block a user