mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Group throwable extension together
This commit is contained in:
parent
83126d5f55
commit
c54358831f
5 changed files with 12 additions and 12 deletions
|
@ -14,13 +14,15 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.riotx.core.error
|
||||
package im.vector.matrix.android.api.failure
|
||||
|
||||
import im.vector.matrix.android.api.failure.Failure
|
||||
import im.vector.matrix.android.api.failure.MatrixError
|
||||
import javax.net.ssl.HttpsURLConnection
|
||||
|
||||
fun Throwable.is401(): Boolean {
|
||||
return (this is Failure.ServerError && httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */
|
||||
&& error.code == MatrixError.M_UNAUTHORIZED)
|
||||
}
|
||||
fun Throwable.is401() =
|
||||
this is Failure.ServerError
|
||||
&& httpCode == HttpsURLConnection.HTTP_UNAUTHORIZED /* 401 */
|
||||
&& error.code == MatrixError.M_UNAUTHORIZED
|
||||
|
||||
fun Throwable.isTokenError() =
|
||||
this is Failure.ServerError
|
||||
&& (error.code == MatrixError.M_UNKNOWN_TOKEN || error.code == MatrixError.M_MISSING_TOKEN)
|
|
@ -44,5 +44,3 @@ sealed class Failure(cause: Throwable? = null) : Throwable(cause = cause) {
|
|||
|
||||
abstract class FeatureFailure : Failure()
|
||||
}
|
||||
|
||||
fun Throwable.isTokenError() = this is Failure.ServerError && (this.error.code == MatrixError.M_UNKNOWN_TOKEN || this.error.code == MatrixError.M_MISSING_TOKEN)
|
||||
|
|
|
@ -30,8 +30,8 @@ import com.google.i18n.phonenumbers.PhoneNumberUtil
|
|||
import com.jakewharton.rxbinding3.widget.textChanges
|
||||
import im.vector.matrix.android.api.auth.registration.RegisterThreePid
|
||||
import im.vector.matrix.android.api.failure.Failure
|
||||
import im.vector.matrix.android.api.failure.is401
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.error.is401
|
||||
import im.vector.riotx.core.extensions.hideKeyboard
|
||||
import im.vector.riotx.core.extensions.isEmail
|
||||
import im.vector.riotx.core.extensions.setTextOrHide
|
||||
|
|
|
@ -20,8 +20,8 @@ import androidx.appcompat.app.AlertDialog
|
|||
import butterknife.OnClick
|
||||
import com.airbnb.mvrx.Fail
|
||||
import com.airbnb.mvrx.Success
|
||||
import im.vector.matrix.android.api.failure.is401
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.error.is401
|
||||
import kotlinx.android.synthetic.main.fragment_login_reset_password_mail_confirmation.*
|
||||
import javax.inject.Inject
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ import android.os.Bundle
|
|||
import android.os.Parcelable
|
||||
import android.view.View
|
||||
import com.airbnb.mvrx.args
|
||||
import im.vector.matrix.android.api.failure.is401
|
||||
import im.vector.riotx.R
|
||||
import im.vector.riotx.core.error.is401
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import kotlinx.android.synthetic.main.fragment_login_wait_for_email.*
|
||||
import javax.inject.Inject
|
||||
|
|
Loading…
Reference in a new issue