mirror of
https://github.com/elyby/chrly.git
synced 2025-05-31 14:11:51 +05:30
Add rough sentry reporting to catch panic in the mojang textures decoder
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package mojangtextures
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/getsentry/raven-go"
|
||||
|
||||
"github.com/elyby/chrly/api/mojang"
|
||||
|
||||
"github.com/tevino/abool"
|
||||
@@ -75,9 +78,22 @@ func (s *InMemoryTexturesStorage) GetTextures(uuid string) (*mojang.SignedTextur
|
||||
func (s *InMemoryTexturesStorage) StoreTextures(uuid string, textures *mojang.SignedTexturesResponse) {
|
||||
var timestamp int64
|
||||
if textures != nil {
|
||||
decoded := textures.DecodeTextures()
|
||||
if decoded == nil {
|
||||
panic("unable to decode textures")
|
||||
decoded, err := textures.DecodeTextures()
|
||||
if err != nil {
|
||||
tags := map[string]string{
|
||||
"textures.id": textures.Id,
|
||||
"textures.name": textures.Name,
|
||||
}
|
||||
|
||||
for i, prop := range textures.Props {
|
||||
tags[fmt.Sprintf("textures.props[%d].name", i)] = prop.Name
|
||||
tags[fmt.Sprintf("textures.props[%d].value", i)] = prop.Value
|
||||
tags[fmt.Sprintf("textures.props[%d].signature", i)] = prop.Signature
|
||||
}
|
||||
|
||||
raven.CaptureErrorAndWait(err, tags)
|
||||
|
||||
panic(err)
|
||||
}
|
||||
|
||||
timestamp = decoded.Timestamp
|
||||
|
@@ -116,7 +116,7 @@ func TestInMemoryTexturesStorage_StoreTextures(t *testing.T) {
|
||||
Props: []*mojang.Property{},
|
||||
}
|
||||
|
||||
assert.PanicsWithValue(t, "unable to decode textures", func() {
|
||||
assert.PanicsWithError(t, "unable to find the textures property", func() {
|
||||
storage := NewInMemoryTexturesStorage()
|
||||
storage.StoreTextures("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", toStore)
|
||||
})
|
||||
|
Reference in New Issue
Block a user