summaryrefslogtreecommitdiff
path: root/irc
diff options
context:
space:
mode:
authorHubert Hirtz <hubert@hirtzfr.eu>2020-08-19 16:01:25 +0200
committerHubert Hirtz <hubert@hirtzfr.eu>2020-08-19 21:56:40 +0200
commitb0a5b6c61491ec9df802f87b565aeaedc9313703 (patch)
treef301b061aa6ab0f6aea50ef50dd9362f83a678ec /irc
parentProperly close everything in case of error (diff)
ui: Don't panic when the connection fails
Diffstat (limited to 'irc')
-rw-r--r--irc/states.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/irc/states.go b/irc/states.go
index 762ed71..f91266a 100644
--- a/irc/states.go
+++ b/irc/states.go
@@ -157,8 +157,8 @@ type Session struct {
chBatches map[string]HistoryEvent
}
-func NewSession(conn io.ReadWriteCloser, params SessionParams) (s Session, err error) {
- s = Session{
+func NewSession(conn io.ReadWriteCloser, params SessionParams) (*Session, error) {
+ s := &Session{
conn: conn,
msgs: make(chan Message, 16),
acts: make(chan action, 16),
@@ -180,9 +180,9 @@ func NewSession(conn io.ReadWriteCloser, params SessionParams) (s Session, err e
s.running.Store(true)
- err = s.send("CAP LS 302\r\nNICK %s\r\nUSER %s 0 * :%s\r\n", s.nick, s.user, s.real)
+ err := s.send("CAP LS 302\r\nNICK %s\r\nUSER %s 0 * :%s\r\n", s.nick, s.user, s.real)
if err != nil {
- return
+ return nil, err
}
go func() {
@@ -206,7 +206,7 @@ func NewSession(conn io.ReadWriteCloser, params SessionParams) (s Session, err e
go s.run()
- return
+ return s, nil
}
func (s *Session) Running() bool {