From c0aefddb1ee75d4d0a36d8db197755469687bfc8 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 31 Jul 2023 18:21:31 +0200 Subject: panic when data to send to a client can not be marshaled --- connection.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'connection.go') diff --git a/connection.go b/connection.go index 4901fdd..e16c942 100644 --- a/connection.go +++ b/connection.go @@ -67,12 +67,11 @@ func (c *Connection) Send(ev Event) { c.refs.Add(-1) } -func (conn *Connection) _send(evs []interface{}) error { +func (conn *Connection) _send(evs []interface{}) { for _, ev := range evs { data, err := json.Marshal(ev) if err != nil { - llog.Warning("Encoding the initial command %v failed with %s", ev, err) - return err + llog.Fatal("Encoding the initial command %v failed with %s", ev, err) } sdata := string(data) @@ -80,12 +79,10 @@ func (conn *Connection) _send(evs []interface{}) error { fmt.Fprintf(conn.w, "data: %s\n\n", sdata) conn.flusher.Flush() } - - return nil } -func (conn *Connection) _sendEv(ev Event) error { - return conn._send([]interface{}{ev}) +func (conn *Connection) _sendEv(ev Event) { + conn._send([]interface{}{ev}) } func (conn *Connection) serve() { -- cgit v1.2.3