Added error recovery to handleEvent
This commit is contained in:
parent
70a13eec00
commit
ee1564e65f
@ -4,6 +4,7 @@ import (
|
|||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
@ -40,6 +41,13 @@ func (s *Server) HandleConnection(conn net.Conn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) handleEvent(e Event) {
|
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)
|
fields := strings.Fields(e.input)
|
||||||
|
|
||||||
if len(fields) < 1 {
|
if len(fields) < 1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user