-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.go
More file actions
26 lines (22 loc) · 801 Bytes
/
errors.go
File metadata and controls
26 lines (22 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package main
import (
"time"
"github.com/getsentry/sentry-go"
"github.com/oomph-ac/oomph/player"
"github.com/sandertv/gophertunnel/minecraft/text"
)
func recoverPlayerFn(p *player.Player, err any) {
// Print the entire stack trace into stdout
//debug.PrintStack()
hub := sentry.CurrentHub().Clone()
hub.WithScope(func(scope *sentry.Scope) {
scope.SetTag("xuid", p.Conn().IdentityData().XUID)
scope.SetTag("player_ign", p.IdentityDat.DisplayName)
if c := p.Conn(); c != nil {
scope.SetTag("client_addr", c.RemoteAddr().String())
}
})
sentryErrID := hub.Recover(err)
_ = hub.Flush(5 * time.Second)
p.Disconnect(text.Colourf("<red><bold>An error occured while processing your connection.\nMake a report with the provided error ID.</bold></red>\nError ID: %s", *sentryErrID))
}