diff --git a/app/websockets/main_handler.go b/app/websockets/main_handler.go index 74cb995..632d3ae 100644 --- a/app/websockets/main_handler.go +++ b/app/websockets/main_handler.go @@ -12,6 +12,7 @@ import ( var stepNumber uint64 func handler(rawConn *websocket.Conn) { + defer catchPanic() defer rawConn.Close() step := atomic.AddUint64(&stepNumber, 1) diff --git a/app/websockets/scores.go b/app/websockets/scores.go index c6af733..910c250 100644 --- a/app/websockets/scores.go +++ b/app/websockets/scores.go @@ -75,6 +75,7 @@ type score struct { } func handleNewScore(id string) { + defer catchPanic() var s score err := db.Get(&s, ` SELECT @@ -131,3 +132,11 @@ func inModes(modes []int, i int) bool { } return false } + +func catchPanic() { + r := recover() + if r != nil { + fmt.Println(r) + // TODO: sentry + } +}