1
0
Fork 0
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:
Michael Bahr 2026-06-11 13:47:36 +00:00
parent 4756698b1e
commit 95b3fbfc6d
No known key found for this signature in database
3 changed files with 8 additions and 4 deletions

View file

@ -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.