@@ -38,6 +38,8 @@ const (
38
38
ErrorMessageReconnectRequired = "client: reconnect required"
39
39
// ErrorMessageSendFailed is an error message.
40
40
ErrorMessageSendFailed = "client: send failed"
41
+ // ErrorMessageServiceError is an error message.
42
+ ErrorMessageServiceError = "client: service error"
41
43
// ErrorMessageUnprocessableResponse is an error message.
42
44
ErrorMessageUnprocessableResponse = "client: unprocessable response"
43
45
)
@@ -124,6 +126,25 @@ func (e *RequiresReconnectError) Error() string {
124
126
return fmt .Sprintf ("%s: no service for type '%s'" , ErrorMessageReconnectRequired , e .Cause .Error ())
125
127
}
126
128
129
+ // ServiceRPCError is returned when the client responds with
130
+ // a response header with is_error true.
131
+ type ServiceRPCError struct {
132
+ Cause * ybApi.ErrorStatusPB
133
+ }
134
+
135
+ func (e * ServiceRPCError ) Error () string {
136
+ codeString := ybApi .ErrorStatusPB_RpcErrorCodePB_name [int32 (ybApi .ErrorStatusPB_FATAL_UNKNOWN )]
137
+ if e .Cause .Code != nil {
138
+ if v , ok := ybApi .ErrorStatusPB_RpcErrorCodePB_name [int32 (* e .Cause .Code )]; ok {
139
+ codeString = v
140
+ }
141
+ }
142
+ if e .Cause .Message == nil {
143
+ return fmt .Sprintf ("%s: %s" , ErrorMessageServiceError , codeString )
144
+ }
145
+ return fmt .Sprintf ("%s: %s: %s" , ErrorMessageServiceError , codeString , * e .Cause .Message )
146
+ }
147
+
127
148
// SendError is returned when the client is unable to
128
149
// send the payload or receive from the server.
129
150
type SendError struct {
0 commit comments