mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-17 12:40:03 +02:00
Use errors.Is/errors.As instead of == comparisons against errors
This commit is contained in:
parent
4756698b1e
commit
95b3fbfc6d
3 changed files with 8 additions and 4 deletions
|
|
@ -3,6 +3,7 @@
|
|||
package websocket
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
|
||||
ws "github.com/gorilla/websocket"
|
||||
|
|
@ -28,7 +29,8 @@ func (t ObjectStream) WriteObject(obj interface{}) error {
|
|||
// ReadObject implements jsonrpc2.ObjectStream.
|
||||
func (t ObjectStream) ReadObject(v interface{}) error {
|
||||
err := t.conn.ReadJSON(v)
|
||||
if e, ok := err.(*ws.CloseError); ok {
|
||||
var e *ws.CloseError
|
||||
if errors.As(err, &e) {
|
||||
if e.Code == ws.CloseAbnormalClosure && e.Text == io.ErrUnexpectedEOF.Error() {
|
||||
// Suppress a noisy (but harmless) log message by
|
||||
// unwrapping this error.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue