Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 2a0edc2

Browse files
Adding functionality to display error message
1 parent 88d3a54 commit 2a0edc2

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

src/GitHub.App/SampleData/ForkRepositoryExecuteViewModelDesigner.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public ForkRepositoryExecuteViewModelDesigner()
5050

5151
public bool CanResetMasterTracking => UpdateOrigin && AddUpstream;
5252

53+
public string Error { get; } = "I AM ERROR";
54+
5355
public Task InitializeAsync(ILocalRepositoryModel sourceRepository, IAccount destinationAccount, IConnection connection)
5456
{
5557
return Task.CompletedTask;

src/GitHub.App/ViewModels/Dialog/ForkRepositoryExecuteViewModel.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,10 @@ IObservable<Repository> OnCreateFork(object o)
9898
.ForkRepository(apiClient, SourceRepository, newRepositoryFork, UpdateOrigin, CanAddUpstream && AddUpstream, CanResetMasterTracking && ResetMasterTracking)
9999
.Catch<Repository, Exception>(ex =>
100100
{
101-
if (!ex.IsCriticalException())
102-
{
103-
log.Error(ex, "Error Creating Fork");
104-
var error = ex.GetUserFriendlyErrorMessage(ErrorType.RepoForkFailed);
105-
notificationService.ShowError(error);
106-
}
101+
log.Error(ex, "Error Creating Fork");
102+
103+
var apiEx = ex as ApiException;
104+
Error = apiEx != null ? apiEx.Message : "An unexpected error occurred.";
107105

108106
return Observable.Return<Repository>(null);
109107
});
@@ -143,5 +141,12 @@ public bool ResetMasterTracking
143141
get { return resetMasterTracking; }
144142
set { this.RaiseAndSetIfChanged(ref resetMasterTracking, value); }
145143
}
144+
145+
string error = null;
146+
public string Error
147+
{
148+
get { return error; }
149+
private set { this.RaiseAndSetIfChanged(ref error, value); }
150+
}
146151
}
147152
}

src/GitHub.Exports.Reactive/ViewModels/Dialog/IForkRepositoryExecuteViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public interface IForkRepositoryExecuteViewModel : IDialogContentViewModel
3333

3434
bool CanResetMasterTracking { get; }
3535

36+
string Error { get; }
37+
3638
/// <summary>
3739
/// Initializes the view model.
3840
/// </summary>

src/GitHub.VisualStudio/Views/Dialog/ForkRepositoryExecuteView.xaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:markdig="clr-namespace:Markdig.Wpf;assembly=Markdig.Wpf"
77
xmlns:sampleData="clr-namespace:GitHub.SampleData;assembly=GitHub.App"
8+
xmlns:ui="https://github.com/github/VisualStudio"
89
Margin="8"
9-
mc:Ignorable="d"
10-
d:DesignHeight="300" d:DesignWidth="300">
10+
mc:Ignorable="d" d:DesignWidth="300" Height="315.179">
1111

1212
<d:DesignProperties.DataContext>
1313
<sampleData:ForkRepositoryExecuteViewModelDesigner/>
@@ -72,7 +72,14 @@
7272
</DockPanel>
7373
</Border>
7474
<Border Style="{StaticResource ItemBorder}">
75-
<Button Click="repoForkButton_OnClick">Fork Repo</Button>
75+
<StackPanel >
76+
<Button Click="repoForkButton_OnClick">Fork Repo</Button>
77+
<TextBlock TextWrapping="Wrap"
78+
Foreground="Red"
79+
Text="{Binding Error, Mode=OneWay}"
80+
HorizontalAlignment="Center"
81+
Visibility="{Binding Error, Converter={ui:NullToVisibilityConverter}}"/>
82+
</StackPanel>
7683
</Border>
7784
</ItemsControl>
7885
</StackPanel>

0 commit comments

Comments
 (0)