Skip to content

Commit

Permalink
Add error message when file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingosse committed Jul 4, 2024
1 parent 115200a commit 07a1bd2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/GummyCat/GummyCat.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.5" />
<PackageReference Include="MessageBox.Avalonia" Version="3.1.5.1" />
<PackageReference Include="Microsoft.Diagnostics.Runtime" Version="3.1.506101" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.1.8" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down
17 changes: 13 additions & 4 deletions src/GummyCat/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Microsoft.Diagnostics.Tracing.Analysis;
using Microsoft.Diagnostics.Tracing.Analysis.GC;
using Microsoft.Diagnostics.Tracing.Parsers;
using MsBox.Avalonia;
using Newtonsoft.Json;

namespace GummyCat;
Expand Down Expand Up @@ -99,7 +100,7 @@ public MainWindow()

public ObservableCollection<Gc> GCs { get; } = new();

private void Window_Loaded(object sender, RoutedEventArgs e)
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
var args = Environment.GetCommandLineArgs();

Expand All @@ -111,7 +112,15 @@ private void Window_Loaded(object sender, RoutedEventArgs e)
}
else
{
Load(args[1]);
try
{
Load(args[1]);
}
catch (IOException ex)
{
await MessageBoxManager.GetMessageBoxStandard("Error", ex.Message, icon: MsBox.Avalonia.Enums.Icon.Error)
.ShowAsync();
}
}
}

Expand Down Expand Up @@ -425,7 +434,7 @@ private void RefreshView(Frame? frame = null)
}
}
}

// Remove regions that weren't marked
PanelRegions.Children.RemoveAll(regions.Where(r => r.Tag != null));

Expand All @@ -434,7 +443,7 @@ private void RefreshView(Frame? frame = null)
// Add the placeholders
ulong lastRegionEnd = 0;

for (int i = 0; i < PanelRegions.Children.Count; i++)
for (int i = 0; i < PanelRegions.Children.Count; i++)
{
var region = PanelRegions.Children[i] as Region;

Expand Down

0 comments on commit 07a1bd2

Please sign in to comment.