summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/slack-go/slack/websocket_managed_conn.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-08-13 16:14:26 +0200
committerGitHub <noreply@github.com>2022-08-13 16:14:26 +0200
commit6a3fc713978a0c1c9290a4afd08b47886b49b635 (patch)
treeaa62cd85cf5671646c75ee38b3fc140ef7edcea8 /vendor/github.com/slack-go/slack/websocket_managed_conn.go
parent3c4192ebf6a32e30cdd23a9644c2ceca72a006fa (diff)
downloadmatterbridge-msglm-6a3fc713978a0c1c9290a4afd08b47886b49b635.tar.gz
matterbridge-msglm-6a3fc713978a0c1c9290a4afd08b47886b49b635.tar.bz2
matterbridge-msglm-6a3fc713978a0c1c9290a4afd08b47886b49b635.zip
Update dependencies and go1.18 (#1873)
* Update dependencies and go1.18 * Exclude unnecessary linters and update build to go1.18
Diffstat (limited to 'vendor/github.com/slack-go/slack/websocket_managed_conn.go')
-rw-r--r--vendor/github.com/slack-go/slack/websocket_managed_conn.go27
1 files changed, 26 insertions, 1 deletions
diff --git a/vendor/github.com/slack-go/slack/websocket_managed_conn.go b/vendor/github.com/slack-go/slack/websocket_managed_conn.go
index 14dea219..f107b2a4 100644
--- a/vendor/github.com/slack-go/slack/websocket_managed_conn.go
+++ b/vendor/github.com/slack-go/slack/websocket_managed_conn.go
@@ -16,6 +16,31 @@ import (
"github.com/slack-go/slack/internal/timex"
)
+// UnmappedError represents error occurred when there is no mapping between given event name
+// and corresponding Go struct.
+type UnmappedError struct {
+ // EventType returns event type name.
+ EventType string
+ // RawEvent returns raw event body.
+ RawEvent json.RawMessage
+
+ ctxMsg string
+}
+
+// NewUnmappedError returns new UnmappedError instance.
+func NewUnmappedError(ctxMsg, eventType string, raw json.RawMessage) *UnmappedError {
+ return &UnmappedError{
+ ctxMsg: ctxMsg,
+ EventType: eventType,
+ RawEvent: raw,
+ }
+}
+
+// Error returns human-readable error message.
+func (u UnmappedError) Error() string {
+ return fmt.Sprintf("%s: Received unmapped event %q", u.ctxMsg, u.EventType)
+}
+
// ManageConnection can be called on a Slack RTM instance returned by the
// NewRTM method. It will connect to the slack RTM API and handle all incoming
// and outgoing events. If a connection fails then it will attempt to reconnect
@@ -474,7 +499,7 @@ func (rtm *RTM) handleEvent(typeStr string, event json.RawMessage) {
v, exists := EventMapping[typeStr]
if !exists {
rtm.Debugf("RTM Error - received unmapped event %q: %s\n", typeStr, string(event))
- err := fmt.Errorf("RTM Error: Received unmapped event %q", typeStr)
+ err := NewUnmappedError("RTM Error", typeStr, event)
rtm.IncomingEvents <- RTMEvent{"unmarshalling_error", &UnmarshallingErrorEvent{err}}
return
}