diff --git a/examples/websocket/websocket.go b/examples/websocket/websocket.go index 2d5406a..2686022 100644 --- a/examples/websocket/websocket.go +++ b/examples/websocket/websocket.go @@ -43,6 +43,9 @@ case slack.LatencyReport: a := msg.Data.(slack.LatencyReport) fmt.Printf("Current latency: %v\n", a.Value) + case *slack.SlackWSError: + error := msg.Data.(*slack.SlackWSError) + fmt.Printf("Error: %d - %s\n", error.Code, error.Msg) default: fmt.Printf("Unexpected: %v\n", msg.Data) } diff --git a/messages.go b/messages.go index b6da8e7..be309e8 100644 --- a/messages.go +++ b/messages.go @@ -60,14 +60,6 @@ ReplyTo int `json:"reply_to"` } -// AckMessage is used for messages received in reply to other messages -type AckMessage struct { - ReplyTo int `json:"reply_to"` - Timestamp string `json:"ts"` - Text string `json:"text"` - SlackResponse -} - // NewOutGoingMessage prepares an OutgoingMessage that the user can use to send a message func (api *SlackWS) NewOutgoingMessage(text string, channel string) *OutgoingMessage { api.mutex.Lock() diff --git a/websocket.go b/websocket.go index 5d9c050..b2f3301 100644 --- a/websocket.go +++ b/websocket.go @@ -22,6 +22,14 @@ mutex sync.Mutex pings map[int]time.Time Slack +} + +// AckMessage is used for messages received in reply to other messages +type AckMessage struct { + ReplyTo int `json:"reply_to"` + Timestamp string `json:"ts"` + Text string `json:"text"` + SlackWSResponse } type SlackWSResponse struct { @@ -191,8 +199,8 @@ return } - // TODO: errors end up in this bucket. They shouldn't. - log.Printf("Got error(?): %s", event) + // Send the error to the user + ch <- SlackEvent{Data: ack.Error} case "hello": ch <- SlackEvent{Data: HelloEvent{}} case "pong":