send client error if it exists
This commit is contained in:
		| @@ -126,6 +126,7 @@ func setHeaders(m *codec.Message) { | ||||
| 	set("Micro-Service", m.Target) | ||||
| 	set("Micro-Method", m.Method) | ||||
| 	set("Micro-Endpoint", m.Endpoint) | ||||
| 	set("Micro-Error", m.Error) | ||||
| } | ||||
|  | ||||
| // setupProtocol sets up the old protocol | ||||
|   | ||||
| @@ -2,6 +2,8 @@ package server | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"errors" | ||||
| 	"io" | ||||
| 	"sync" | ||||
|  | ||||
| 	"github.com/micro/go-micro/codec" | ||||
| @@ -59,6 +61,20 @@ func (r *rpcStream) Recv(msg interface{}) error { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| 	// check the error | ||||
| 	if len(req.Error) > 0 { | ||||
| 		// Check the client closed the stream | ||||
| 		switch req.Error { | ||||
| 		case lastStreamResponseError.Error(): | ||||
| 			// discard body | ||||
| 			r.codec.ReadBody(nil) | ||||
| 			r.err = io.EOF | ||||
| 			return io.EOF | ||||
| 		default: | ||||
| 			return errors.New(req.Error) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	// we need to stay up to date with sequence numbers | ||||
| 	r.id = req.Id | ||||
| 	if err := r.codec.ReadBody(msg); err != nil { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user