From 7fd1dccf0648bb2627a3938856181563f95d53ad Mon Sep 17 00:00:00 2001 From: Koichi Shiraishi Date: Thu, 11 Jun 2020 01:19:05 +0900 Subject: [PATCH] msgpack/rpc: export ErrClosed and ErrInternal --- msgpack/rpc/endpoint.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/msgpack/rpc/endpoint.go b/msgpack/rpc/endpoint.go index 455ee69f..79db0d68 100644 --- a/msgpack/rpc/endpoint.go +++ b/msgpack/rpc/endpoint.go @@ -24,8 +24,11 @@ const ( ) var ( - errClosed = errors.New("msgpack/rpc: session closed") - errInternal = errors.New("msgpack/rpc: internal error") + // ErrClosed session closed error. + ErrClosed = errors.New("msgpack/rpc: session closed") + + // ErrInternal msgpack-rpc internal error. + ErrInternal = errors.New("msgpack/rpc: internal error") ) type Error struct { @@ -212,7 +215,7 @@ func (e *Endpoint) close(err error) error { e.state = stateClosed e.err = err for _, call := range e.pending { - call.done(e, errClosed) + call.done(e, ErrClosed) } e.pending = nil err = e.closer.Close() @@ -252,7 +255,7 @@ func (e *Endpoint) Go(method string, done chan *Call, reply interface{}, args .. e.mu.Lock() if e.state == stateClosed { - call.done(e, errClosed) + call.done(e, ErrClosed) e.mu.Unlock() return call } @@ -423,7 +426,7 @@ func (e *Endpoint) handleReply(messageLen int) error { var errorValue interface{} if err := e.dec.Decode(&errorValue); err != nil { - call.done(e, errInternal) + call.done(e, ErrInternal) return fmt.Errorf("msgpack/rpc: error decoding error value: %v", err) } @@ -444,7 +447,7 @@ func (e *Endpoint) handleReply(messageLen int) error { } if err != nil { - call.done(e, errInternal) + call.done(e, ErrInternal) return fmt.Errorf("msgpack/rpc: error decoding reply: %v", err) }