Add some logs to try to understand an error on the production app. Also propagate the exception if this is not a registration flow response.
This commit is contained in:
parent
d52e61413d
commit
df957971a8
|
@ -36,6 +36,7 @@ import org.matrix.android.sdk.internal.session.sync.model.accountdata.AcceptedTe
|
||||||
import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask
|
import org.matrix.android.sdk.internal.session.user.accountdata.UpdateUserAccountDataTask
|
||||||
import org.matrix.android.sdk.internal.session.user.accountdata.UserAccountDataDataSource
|
import org.matrix.android.sdk.internal.session.user.accountdata.UserAccountDataDataSource
|
||||||
import org.matrix.android.sdk.internal.util.ensureTrailingSlash
|
import org.matrix.android.sdk.internal.util.ensureTrailingSlash
|
||||||
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
internal class DefaultTermsService @Inject constructor(
|
internal class DefaultTermsService @Inject constructor(
|
||||||
|
@ -63,19 +64,28 @@ internal class DefaultTermsService @Inject constructor(
|
||||||
*/
|
*/
|
||||||
override suspend fun getHomeserverTerms(baseUrl: String): TermsResponse {
|
override suspend fun getHomeserverTerms(baseUrl: String): TermsResponse {
|
||||||
return try {
|
return try {
|
||||||
|
val request = baseUrl + NetworkConstants.URI_API_PREFIX_PATH_R0 + "register"
|
||||||
executeRequest(null) {
|
executeRequest(null) {
|
||||||
termsAPI.register(baseUrl + NetworkConstants.URI_API_PREFIX_PATH_R0 + "register")
|
termsAPI.register(request)
|
||||||
}
|
}
|
||||||
// Return empty result if it succeed, but it should never happen
|
// Return empty result if it succeed, but it should never happen
|
||||||
|
Timber.w("Request $request succeeded, it should never happen")
|
||||||
TermsResponse()
|
TermsResponse()
|
||||||
} catch (throwable: Throwable) {
|
} catch (throwable: Throwable) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
val registrationFlowResponse = throwable.toRegistrationFlowResponse()
|
||||||
TermsResponse(
|
if (registrationFlowResponse != null) {
|
||||||
policies = (throwable.toRegistrationFlowResponse()
|
@Suppress("UNCHECKED_CAST")
|
||||||
?.params
|
TermsResponse(
|
||||||
?.get(LoginFlowTypes.TERMS) as? JsonDict)
|
policies = (registrationFlowResponse
|
||||||
?.get("policies") as? JsonDict
|
.params
|
||||||
)
|
?.get(LoginFlowTypes.TERMS) as? JsonDict)
|
||||||
|
?.get("policies") as? JsonDict
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
// Other error
|
||||||
|
Timber.e(throwable, "Error while getting homeserver terms")
|
||||||
|
throw throwable
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue