Added error recovery to handleEvent

This commit is contained in:
Harry Jeffery 2013-08-29 20:55:17 +01:00
parent 70a13eec00
commit ee1564e65f

View File

@ -4,6 +4,7 @@ import (
"crypto/sha1"
"fmt"
"io"
"log"
"net"
"regexp"
"strings"
@ -40,6 +41,13 @@ func (s *Server) HandleConnection(conn net.Conn) {
}
func (s *Server) handleEvent(e Event) {
defer func(event Event) {
err := recover()
if err != nil {
log.Printf("Recovered from errer when handling event: %+v", event)
log.Println(err)
}
}(e)
fields := strings.Fields(e.input)
if len(fields) < 1 {