fix crash in EditProfileViewModel

main
Conny Duck 6 years ago
parent 37da617bdb
commit 937436091b
  1. 5
      app/src/main/java/com/keylesspalace/tusky/viewmodel/EditProfileViewModel.kt

@ -35,6 +35,7 @@ import io.reactivex.schedulers.Schedulers
import okhttp3.MediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody
import org.json.JSONException
import org.json.JSONObject
import retrofit2.Call
import retrofit2.Callback
@ -199,7 +200,11 @@ class EditProfileViewModel @Inject constructor(
if (!response.isSuccessful || newProfileData == null) {
val errorResponse = response.errorBody()?.string()
val errorMsg = if(!errorResponse.isNullOrBlank()) {
try {
JSONObject(errorResponse).optString("error", null)
} catch (e: JSONException) {
null
}
} else {
null
}

Loading…
Cancel
Save