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

Crash when use policy #5891

Closed
enggazzar opened this issue May 15, 2024 · 6 comments
Closed

Crash when use policy #5891

enggazzar opened this issue May 15, 2024 · 6 comments
Labels
⌛ Waiting for info More information is required ❓ Type: Question

Comments

@enggazzar
Copy link

Version

3.8.2

Summary

Capture
override suspend fun getMerchantsByKeyWord(keyword:String): Flow<Response> {
return apolloClient.query(MerchantsByKeyWordQuery(keyword)).fetchPolicy(FetchPolicy.CacheAndNetwork)
.toFlow()
.map { response ->
try {
//response.data.merchants
Response.Success(response.data?.toRestaurantsSearch() as T)
} catch (e: Exception) {
Response.Failure( e.message ?: "unknown error")
}
}
}

Steps to reproduce the behavior

No response

Logs

(Your logs here)
@BoD
Copy link
Contributor

BoD commented May 15, 2024

Hi! It looks like you're having a network issue. This can happen if your device has a connectivity issue, or e.g. if the backend is not responding.

@enggazzar
Copy link
Author

I enabled working offline from cache policy

@BoD
Copy link
Contributor

BoD commented May 15, 2024

CacheAndNetwork will both go to the cache and the network, which will throw if the network fails.

@enggazzar
Copy link
Author

I disable wifi to test app working offline

@BoD
Copy link
Contributor

BoD commented May 15, 2024

In that case what you're seeing is definitely expected. You should probably add a .catch {} call to the Flow chain, to handle the exception.

@BoD BoD added ❓ Type: Question ⌛ Waiting for info More information is required and removed 🐛 Type: Bug labels May 15, 2024
@BoD
Copy link
Contributor

BoD commented May 20, 2024

Hi! Anything else we can do here?

@martinbonnin martinbonnin closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⌛ Waiting for info More information is required ❓ Type: Question
Projects
None yet
Development

No branches or pull requests

3 participants