mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-11 06:29:29 +01:00
clean up some error handling
This commit is contained in:
parent
daefa40b75
commit
15c54e80de
@ -73,13 +73,6 @@ var (
|
|||||||
errRegisteredOnly = errors.New("Cannot join registered-only channel without an account")
|
errRegisteredOnly = errors.New("Cannot join registered-only channel without an account")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Socket Errors
|
|
||||||
var (
|
|
||||||
errNoPeerCerts = errors.New("Client did not provide a certificate")
|
|
||||||
errNotTLS = errors.New("Not a TLS connection")
|
|
||||||
errReadQ = errors.New("ReadQ Exceeded")
|
|
||||||
)
|
|
||||||
|
|
||||||
// String Errors
|
// String Errors
|
||||||
var (
|
var (
|
||||||
errCouldNotStabilize = errors.New("Could not stabilize string while casefolding")
|
errCouldNotStabilize = errors.New("Could not stabilize string while casefolding")
|
||||||
|
@ -3,6 +3,7 @@ package irc
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"net"
|
"net"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
@ -18,6 +19,7 @@ const (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
crlf = []byte{'\r', '\n'}
|
crlf = []byte{'\r', '\n'}
|
||||||
|
errReadQ = errors.New("ReadQ Exceeded")
|
||||||
)
|
)
|
||||||
|
|
||||||
// IRCConn abstracts away the distinction between a regular
|
// IRCConn abstracts away the distinction between a regular
|
||||||
@ -31,7 +33,7 @@ type IRCConn interface {
|
|||||||
// these take an IRC line or lines, correctly terminated with CRLF:
|
// these take an IRC line or lines, correctly terminated with CRLF:
|
||||||
WriteLine([]byte) error
|
WriteLine([]byte) error
|
||||||
WriteLines([][]byte) error
|
WriteLines([][]byte) error
|
||||||
// this returns an IRC line without the terminating CRLF:
|
// this returns an IRC line, possibly terminated with CRLF, LF, or nothing:
|
||||||
ReadLine() (line []byte, err error)
|
ReadLine() (line []byte, err error)
|
||||||
|
|
||||||
Close() error
|
Close() error
|
||||||
@ -127,6 +129,9 @@ func (wc IRCWSConn) ReadLine() (line []byte, err error) {
|
|||||||
messageType, line, err = wc.conn.ReadMessage()
|
messageType, line, err = wc.conn.ReadMessage()
|
||||||
// on empty message or non-text message, try again, block if necessary
|
// on empty message or non-text message, try again, block if necessary
|
||||||
if err != nil || (messageType == websocket.TextMessage && len(line) != 0) {
|
if err != nil || (messageType == websocket.TextMessage && len(line) != 0) {
|
||||||
|
if err == websocket.ErrReadLimit {
|
||||||
|
err = errReadQ
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user