Skip to content

Commit 34e3555

Browse files
committed
log json when failing to decode gateway message
1 parent b69438c commit 34e3555

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

gateway/gateway_messages.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package gateway
22

33
import (
4+
"fmt"
5+
46
"github.com/disgoorg/json"
57
"github.com/disgoorg/snowflake/v2"
68

@@ -86,7 +88,7 @@ func (e *Message) UnmarshalJSON(data []byte) error {
8688
messageData = d
8789
}
8890
if err != nil {
89-
return err
91+
return fmt.Errorf("failed to unmarshal message data: %s: %w", string(data), err)
9092
}
9193
e.Op = v.Op
9294
e.S = v.S
@@ -430,7 +432,11 @@ func UnmarshalEventData(data []byte, eventType EventType) (EventData, error) {
430432
eventData = d
431433
}
432434

433-
return eventData, err
435+
if err != nil {
436+
return nil, fmt.Errorf("failed to unmarshal event data: %s: %w", string(data), err)
437+
}
438+
439+
return eventData, nil
434440
}
435441

436442
type MessageDataUnknown json.RawMessage

0 commit comments

Comments
 (0)