use of androidx.annotation.RestrictTo in project FirebaseUI-Android by firebase.
the class IdpResponse method from.
@NonNull
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
public static IdpResponse from(@NonNull Exception e) {
if (e instanceof FirebaseUiException) {
return new IdpResponse((FirebaseUiException) e);
} else if (e instanceof FirebaseAuthAnonymousUpgradeException) {
return ((FirebaseAuthAnonymousUpgradeException) e).getResponse();
} else if (e instanceof FirebaseUiUserCollisionException) {
FirebaseUiUserCollisionException collisionException = (FirebaseUiUserCollisionException) e;
// Lint complains about providerId not being
// in the pre-defined set of constants
@SuppressLint("WrongConstant") User user = new User.Builder(collisionException.getProviderId(), collisionException.getEmail()).build();
return new IdpResponse(user, /* token= */
null, /* secret= */
null, /* isNewUser= */
false, new FirebaseUiException(collisionException.getErrorCode(), collisionException.getMessage()), collisionException.getCredential());
} else {
FirebaseUiException wrapped = new FirebaseUiException(ErrorCodes.UNKNOWN_ERROR, e.getMessage());
wrapped.setStackTrace(e.getStackTrace());
return new IdpResponse(wrapped);
}
}
Aggregations