Browse Source

Add global exception catching

pull/5636/head
2dust 3 months ago
parent
commit
b6c09470fc
  1. 16
      v2rayN/v2rayN.Desktop/App.axaml.cs
  2. 20
      v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml
  3. 1
      v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs
  4. 7
      v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj
  5. BIN
      v2rayN/v2rayN.Desktop/v2rayN.ico

16
v2rayN/v2rayN.Desktop/App.axaml.cs

@ -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()
@ -71,6 +74,19 @@ public partial class App : Application
}
}
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)
{
}

20
v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml

@ -49,6 +49,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@ -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"

1
v2rayN/v2rayN.Desktop/Views/SubEditWindow.axaml.cs

@ -40,6 +40,7 @@ namespace v2rayN.Desktop.Views
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);
});

7
v2rayN/v2rayN.Desktop/v2rayN.Desktop.csproj

@ -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>
@ -35,5 +36,11 @@
<ProjectReference Include="..\ServiceLib\ServiceLib.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="v2rayN.ico">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
</Project>

BIN
v2rayN/v2rayN.Desktop/v2rayN.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Loading…
Cancel
Save