Added error recovery

This commit is contained in:
Harry Jeffery 2013-08-24 00:42:01 +01:00
parent 510f1adc7f
commit 3ffbc1eb62

View File

@ -89,6 +89,15 @@ func NewServer() *Server {
func (s *Server) Run() {
go func() {
for {
event := <-s.eventChan
defer func() {
if err := recover(); err != nil {
log.Printf("Recovered from panic()")
log.Printf("%s sent %q", event.client.nick, event.input)
log.Println(err)
}
}()
s.handleEvent(<-s.eventChan)
}
}()