From d04b1bde39dc73a65e8ddcd550e424c0244de221 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 16 Jul 2023 00:16:36 +0300 Subject: [PATCH] Fix some error messages --- libgm/conversations.go | 12 ++++++------ libgm/messages.go | 4 ++-- libgm/session.go | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libgm/conversations.go b/libgm/conversations.go index 96c758c..3be3ab6 100644 --- a/libgm/conversations.go +++ b/libgm/conversations.go @@ -36,7 +36,7 @@ func (c *Conversations) List(count int64) (*binary.Conversations, error) { res, ok := response.Data.Decrypted.(*binary.Conversations) if !ok { - return nil, fmt.Errorf("failed to assert response into Conversations") + return nil, fmt.Errorf("unexpected response type %T, expected *binary.Conversations", response.Data.Decrypted) } return res, nil @@ -58,7 +58,7 @@ func (c *Conversations) GetType(conversationId string) (*binary.GetConversationT res, ok := response.Data.Decrypted.(*binary.GetConversationTypeResponse) if !ok { - return nil, fmt.Errorf("failed to assert response into GetConversationTypeResponse") + return nil, fmt.Errorf("unexpected response type %T, expected *binary.GetConversationTypeResponse", response.Data.Decrypted) } return res, nil @@ -84,7 +84,7 @@ func (c *Conversations) FetchMessages(conversationId string, count int64, cursor res, ok := response.Data.Decrypted.(*binary.FetchMessagesResponse) if !ok { - return nil, fmt.Errorf("failed to assert response into FetchMessagesResponse") + return nil, fmt.Errorf("unexpected response type %T, expected *binary.FetchMessagesResponse", response.Data.Decrypted) } return res, nil @@ -105,7 +105,7 @@ func (c *Conversations) SendMessage(payload *binary.SendMessagePayload) (*binary res, ok := response.Data.Decrypted.(*binary.SendMessageResponse) if !ok { - return nil, fmt.Errorf("failed to assert response into SendMessageResponse") + return nil, fmt.Errorf("unexpected response type %T, expected *binary.SendMessageResponse", response.Data.Decrypted) } c.client.Logger.Debug().Any("res", res).Msg("sent message!") @@ -128,7 +128,7 @@ func (c *Conversations) GetParticipantThumbnail(convID string) (*binary.Particip res, ok := response.Data.Decrypted.(*binary.ParticipantThumbnail) if !ok { - return nil, fmt.Errorf("failed to assert response into ParticipantThumbnail") + return nil, fmt.Errorf("unexpected response type %T, expected *binary.ParticipantThumbnail", response.Data.Decrypted) } return res, nil @@ -156,7 +156,7 @@ func (c *Conversations) Update(convBuilder *ConversationBuilder) (*binary.Update res, ok := response.Data.Decrypted.(*binary.UpdateConversationResponse) if !ok { - return nil, fmt.Errorf("failed to assert response into UpdateConversationResponse") + return nil, fmt.Errorf("unexpected response type %T, expected *binary.UpdateConversationResponse", response.Data.Decrypted) } return res, nil diff --git a/libgm/messages.go b/libgm/messages.go index eb5a770..4aa3435 100644 --- a/libgm/messages.go +++ b/libgm/messages.go @@ -25,7 +25,7 @@ func (m *Messages) React(payload *binary.SendReactionPayload) (*binary.SendReact res, ok := response.Data.Decrypted.(*binary.SendReactionResponse) if !ok { - return nil, fmt.Errorf("failed to assert response into SendReactionResponse") + return nil, fmt.Errorf("unexpected response type %T, expected *binary.SendReactionResponse", response.Data.Decrypted) } m.client.Logger.Debug().Any("res", res).Msg("sent reaction!") @@ -48,7 +48,7 @@ func (m *Messages) Delete(messageId string) (*binary.DeleteMessageResponse, erro res, ok := response.Data.Decrypted.(*binary.DeleteMessageResponse) if !ok { - return nil, fmt.Errorf("failed to assert response into DeleteMessageResponse") + return nil, fmt.Errorf("unexpected response type %T, expected *binary.DeleteMessagesResponse", response.Data.Decrypted) } m.client.Logger.Debug().Any("res", res).Msg("deleted message!") diff --git a/libgm/session.go b/libgm/session.go index 3ffd2e0..f9ecb40 100644 --- a/libgm/session.go +++ b/libgm/session.go @@ -38,7 +38,7 @@ func (s *Session) IsBugleDefault() (*binary.IsBugleDefaultResponse, error) { res, ok := response.Data.Decrypted.(*binary.IsBugleDefaultResponse) if !ok { - return nil, fmt.Errorf("failed to assert response into IsBugleDefaultResponse") + return nil, fmt.Errorf("unexpected response type %T, expected *binary.IsBugleDefaultResponse", response.Data.Decrypted) } return res, nil