#pragma warning disable CS0618 // Type or member is obsolete void HandleError(Exception ex) { // The Windows ERROR_OPERATION_ABORTED error code. const int operationAborted = 995; if (ex is HttpListenerException && ((HttpListenerException)ex).ErrorCode == operationAborted) { // An Oauth listener was aborted, probably because the user closed the login // dialog or switched between the GitHub and Enterprise tabs while listening // for an Oauth callbacl. return; } if (ex.IsCriticalException()) { return; } log.Error(ex, "Error logging into '{BaseUri}' as '{UsernameOrEmail}'", BaseUri, UsernameOrEmail); if (ex is Octokit.ForbiddenException) { Error = new UserError(Resources.LoginFailedForbiddenMessage, ex.Message); } else { Error = new UserError(ex.Message); } }
#pragma warning disable CS0618 // Type or member is obsolete public IObservable <TwoFactorChallengeResult> Show(ReactiveUI.Legacy.UserError userError) { Guard.ArgumentNotNull(userError, nameof(userError)); IsBusy = false; var error = userError as TwoFactorRequiredUserError; if (error == null) { throw new GitHubLogicException( String.Format( CultureInfo.InvariantCulture, "The user error is '{0}' not a TwoFactorRequiredUserError", userError)); } InvalidAuthenticationCode = error.RetryFailed; IsAuthenticationCodeSent = false; TwoFactorType = error.TwoFactorType; var ok = OkCommand .Do(_ => IsBusy = true) .Select(_ => AuthenticationCode == null ? null : new TwoFactorChallengeResult(AuthenticationCode)); var resend = ResendCodeCommand.Select(_ => ReactiveUI.Legacy.RecoveryOptionResult.RetryOperation) .Select(_ => TwoFactorChallengeResult.RequestResendCode) .Do(_ => IsAuthenticationCodeSent = true); var cancel = this.WhenAnyValue(x => x.TwoFactorType) .Skip(1) .Where(x => x == TwoFactorType.None) .Select(_ => default(TwoFactorChallengeResult)); return(Observable.Merge(ok, cancel, resend).Take(1)); }
ReactiveCommand <Unit, Unit> InitializeCreateRepositoryCommand() { var canCreate = this.WhenAny( x => x.RepositoryNameValidator.ValidationResult.IsValid, x => x.BaseRepositoryPathValidator.ValidationResult.IsValid, (x, y) => x.Value && y.Value); var createCommand = ReactiveCommand.CreateFromObservable(OnCreateRepository, canCreate); createCommand.ThrownExceptions.Subscribe(ex => { if (!Extensions.ExceptionExtensions.IsCriticalException(ex)) { log.Error(ex, "Error creating repository"); #pragma warning disable CS0618 // Type or member is obsolete UserError.Throw(TranslateRepositoryCreateException(ex)); #pragma warning restore CS0618 // Type or member is obsolete } }); return(createCommand); }