@@ -13,9 +13,11 @@ import com.getcode.manager.TopBarManager
1313import com.getcode.navigation.core.CodeNavigator
1414import com.getcode.navigation.screens.LoginPhoneConfirmationScreen
1515import com.getcode.navigation.screens.PhoneConfirmationScreen
16+ import com.getcode.network.repository.ErrorSubmitIntent
1617import com.getcode.network.repository.PhoneRepository
1718import com.getcode.util.PhoneUtils
1819import com.getcode.util.resources.ResourceHelper
20+ import com.getcode.utils.ErrorUtils
1921import com.getcode.utils.makeE164
2022import com.getcode.view.*
2123import com.google.android.gms.auth.api.phone.SmsRetriever
@@ -175,7 +177,7 @@ class PhoneVerifyViewModel @Inject constructor(
175177 }
176178 .doOnComplete { setIsLoading(false ) }
177179 .map { res ->
178- when (res) {
180+ val message = when (res) {
179181 PhoneVerificationService .SendVerificationCodeResponse .Result .OK -> null
180182
181183 PhoneVerificationService .SendVerificationCodeResponse .Result .INVALID_PHONE_NUMBER ,
@@ -185,12 +187,24 @@ class PhoneVerifyViewModel @Inject constructor(
185187 PhoneVerificationService .SendVerificationCodeResponse .Result .UNSUPPORTED_COUNTRY -> {
186188 getUnsupportedCountryError()
187189 }
188- PhoneVerificationService .SendVerificationCodeResponse .Result .UNRECOGNIZED -> {
190+ PhoneVerificationService .SendVerificationCodeResponse .Result .UNRECOGNIZED ,
191+ PhoneVerificationService .SendVerificationCodeResponse .Result .UNSUPPORTED_DEVICE -> {
189192 getUnsupportedDeviceError()
190193 }
191194 else -> getGenericError()
192- }?.let { message -> TopBarManager .showMessage(message) }
193- res == PhoneVerificationService .SendVerificationCodeResponse .Result .OK
195+ }
196+
197+ if (message != null ) {
198+ TopBarManager .showMessage(message)
199+ }
200+
201+ val success = res == PhoneVerificationService .SendVerificationCodeResponse .Result .OK
202+
203+ if (! success) {
204+ ErrorUtils .handleError(PhoneVerifyException (reason = res.name))
205+ }
206+
207+ success
194208 }
195209 .concatMapSingle { isSuccess ->
196210 Single .just(isSuccess).delay(500L , TimeUnit .MILLISECONDS )
@@ -255,3 +269,12 @@ class PhoneVerifyViewModel @Inject constructor(
255269 resources.getString(R .string.error_description_countryNotSupported)
256270 )
257271}
272+
273+ private class PhoneVerifyException (
274+ cause : Throwable ? = null ,
275+ val reason : String ,
276+ ) : Exception(cause) {
277+ override val message: String
278+ get() = " Failed to verify phone number: $reason "
279+ }
280+
0 commit comments