mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
catch http 405 if endpoint is not available.
E.g. for older server versions Without this fix there would be the crash: E FATAL EXCEPTION: main Process: com.nextcloud.talk2, PID: 7161 retrofit2.HttpException: HTTP 405 at retrofit2.KotlinExtensions$await$2$2.onResponse(KotlinExtensions.kt:53) at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:164) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:519) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012) Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@4a67b41, Dispatchers.Main.immediate] Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
3ebad8a49b
commit
c434394c3d
@ -319,14 +319,19 @@ class ConversationInfoViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
fun getProfileData(user: User, userId: String) {
|
fun getProfileData(user: User, userId: String) {
|
||||||
val url = ApiUtils.getUrlForProfile(user.baseUrl!!, userId)
|
val url = ApiUtils.getUrlForProfile(user.baseUrl!!, userId)
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
|
try {
|
||||||
if (profile != null) {
|
val profile = conversationsRepository.getProfile(user.getCredentials(), url)
|
||||||
_getProfileViewState.value = GetProfileSuccessState(profile)
|
if (profile != null) {
|
||||||
} else {
|
_getProfileViewState.value = GetProfileSuccessState(profile)
|
||||||
_getProfileViewState.value = GetProfileErrorState
|
} else {
|
||||||
|
_getProfileViewState.value = GetProfileErrorState
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.w(TAG, "Failed to get profile data (if not supported there wil be http405)", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user