Skip to content

Commit

Permalink
Add global exception catching
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Aug 30, 2024
1 parent 9fdf6c6 commit b6c0947
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
16 changes: 16 additions & 0 deletions v2rayN/v2rayN.Desktop/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public partial class App : Application
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);

AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
}

public override void OnFrameworkInitializationCompleted()
Expand Down Expand Up @@ -71,6 +74,19 @@ private void Init()
}
}

private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject != null)
{
Logging.SaveLog("CurrentDomain_UnhandledException", (Exception)e.ExceptionObject!);
}
}

private void TaskScheduler_UnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)
{
Logging.SaveLog("TaskScheduler_UnobservedTaskException", e.Exception);
}

private void OnExit(object? sender, ControlledApplicationLifetimeExitEventArgs e)
{
}
Expand Down
20 changes: 19 additions & 1 deletion v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -213,13 +214,30 @@
<TextBlock
Grid.Row="11"
Grid.Column="0"
Margin="4"
VerticalAlignment="Center"
Classes="Margin4"
Text="{x:Static resx:ResUI.TbPreSocksPort4Sub}" />
<TextBox
x:Name="txtPreSocksPort"
Grid.Row="11"
Grid.Column="1"
Width="200"
Margin="4"
HorizontalAlignment="Left"
Classes="Margin4"
ToolTip.Tip="{x:Static resx:ResUI.TipPreSocksPort}" />

<TextBlock
Grid.Row="12"
Grid.Column="0"
Grid.ColumnSpan="2"
VerticalAlignment="Center"
Classes="Margin4"
Text="{x:Static resx:ResUI.LvMoreUrl}" />
<TextBox
x:Name="txtMoreUrl"
Grid.Row="12"
Grid.Row="13"
Grid.Column="1"
MinHeight="100"
HorizontalAlignment="Stretch"
Expand Down
1 change: 1 addition & 0 deletions v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public SubEditWindow(SubItem subItem)
this.Bind(ViewModel, vm => vm.SelectedSource.convertTarget, v => v.cmbConvertTarget.SelectedValue).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.prevProfile, v => v.txtPrevProfile.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.nextProfile, v => v.txtNextProfile.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.SelectedSource.preSocksPort, v => v.txtPreSocksPort.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
});
Expand Down
7 changes: 7 additions & 0 deletions v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>v2rayN.ico</ApplicationIcon>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
<FileVersion>6.55</FileVersion>
Expand Down Expand Up @@ -35,5 +36,11 @@
<ProjectReference Include="..\ServiceLib\ServiceLib.csproj" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="v2rayN.ico">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>


</Project>
Binary file added v2rayN/v2rayN.Desktop/v2rayN.ico
Binary file not shown.

0 comments on commit b6c0947

Please sign in to comment.