make sure panics don't slip out of websockets
This commit is contained in:
parent
330b90b172
commit
ace4c6bee0
app/websockets
@ -12,6 +12,7 @@ import (
|
||||
var stepNumber uint64
|
||||
|
||||
func handler(rawConn *websocket.Conn) {
|
||||
defer catchPanic()
|
||||
defer rawConn.Close()
|
||||
|
||||
step := atomic.AddUint64(&stepNumber, 1)
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user