Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw an error during channel fetching #3469

Closed
f3dm76 opened this issue Oct 23, 2024 · 2 comments
Closed

Throw an error during channel fetching #3469

f3dm76 opened this issue Oct 23, 2024 · 2 comments
Labels
❓ Question Question regarding a specific subject

Comments

@f3dm76
Copy link

f3dm76 commented Oct 23, 2024

What are you trying to achieve?

I'm trying to get the error during channel fetching.
chatClient.channelController(for: ChannelId(type: .messaging, id: $0.chatID.lowercased()))
For example the channel with this id could not be created yet or something happened during fetching. And I want to noramlly process this state, asking the user to wait or something.

Why do I want this?

Sometimes it happens right after you connect with someone you tap to go into the chat and it’s just a loading spinner. So I think it might be something going wrong inside the chat controller

If possible, how can you achieve this currently?

What would be the better way?

make channelController a throwing method, and allow the programmer to catch a readable error

GetStream Environment

GetStream Chat version: 4.62.0
GetStream Chat frameworks: StreamChat, StreamChatUI
iOS version: 18.0
Swift version: 6.0
Xcode version: 16.0
Device: sim iPhone 16 pro max

Additional context

@nuno-vieira
Copy link
Member

Hi @f3dm76,

That method won't ever fail unless you use the channelController(createChannelWithId:).

The only way it can fail is in the synchronize method, and in that case, you need to handle the error. To handle this error, if you are using our UI components, you need to override the ChatChannelVC.didFinishSynchronizing(error:) function.

Thank you,
Nuno

@nuno-vieira nuno-vieira added the ❓ Question Question regarding a specific subject label Oct 23, 2024
@f3dm76
Copy link
Author

f3dm76 commented Oct 30, 2024

Hey @nuno-vieira, thank you for your answer, yes I'm using StreamChat's UI components, but the SwiftUI one. I'd like to avoid UIView representable, is there a way to do in it in pure SwiftUI? Have a great day!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❓ Question Question regarding a specific subject
Projects
None yet
Development

No branches or pull requests

2 participants