make sure panics don't slip out of websockets
This commit is contained in:
parent
330b90b172
commit
ace4c6bee0
@ -12,6 +12,7 @@ import (
|
|||||||
var stepNumber uint64
|
var stepNumber uint64
|
||||||
|
|
||||||
func handler(rawConn *websocket.Conn) {
|
func handler(rawConn *websocket.Conn) {
|
||||||
|
defer catchPanic()
|
||||||
defer rawConn.Close()
|
defer rawConn.Close()
|
||||||
|
|
||||||
step := atomic.AddUint64(&stepNumber, 1)
|
step := atomic.AddUint64(&stepNumber, 1)
|
||||||
|
@ -75,6 +75,7 @@ type score struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleNewScore(id string) {
|
func handleNewScore(id string) {
|
||||||
|
defer catchPanic()
|
||||||
var s score
|
var s score
|
||||||
err := db.Get(&s, `
|
err := db.Get(&s, `
|
||||||
SELECT
|
SELECT
|
||||||
@ -131,3 +132,11 @@ func inModes(modes []int, i int) bool {
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func catchPanic() {
|
||||||
|
r := recover()
|
||||||
|
if r != nil {
|
||||||
|
fmt.Println(r)
|
||||||
|
// TODO: sentry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user