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

Commit 72d2d38

Browse files
author
Awbugl
committed
Update Code
1 parent 5b842d4 commit 72d2d38

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

Andreal.Core/Data/Api/ArcaeaUnlimitedApi.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,33 @@ public static void Init(AndrealConfig config)
2323

2424
private static async Task GetStream(string url, Path filename)
2525
{
26-
await using var fileStream
27-
= new FileStream(filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
26+
FileStream? fileStream = null;
2827

2928
try
3029
{
30+
fileStream = new(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
3131
await (await _client!.GetAsync(url)).EnsureSuccessStatusCode().Content.CopyToAsync(fileStream);
32-
fileStream.Close();
3332
}
3433
catch
3534
{
36-
fileStream.Close();
37-
File.Delete(filename);
35+
try
36+
{
37+
File.Delete(filename);
38+
}
39+
catch
40+
{
41+
// ignore
42+
}
43+
44+
throw;
45+
}
46+
finally
47+
{
48+
if (fileStream is not null)
49+
{
50+
fileStream.Close();
51+
await fileStream.DisposeAsync();
52+
}
3853
}
3954
}
4055

Andreal.Window/UI/App.xaml.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Threading.Tasks;
34
using System.Windows;
45
using Andreal.Core.Common;
56
using Andreal.Window.Common;
@@ -18,19 +19,13 @@ protected override void OnStartup(StartupEventArgs e)
1819
args.Handled = true;
1920
};
2021

21-
AppDomain.CurrentDomain.UnhandledException += (_, args) =>
22-
{
23-
ExceptionLogger.Log(args.ExceptionObject as Exception);
24-
try
25-
{
26-
27-
Process.Start(AppContext.BaseDirectory + @"\Andreal.Window.exe");
28-
}
29-
catch
30-
{
31-
// ignore
32-
}
33-
};
22+
TaskScheduler.UnobservedTaskException += (_, args) =>
23+
{
24+
ExceptionLogger.Log(args.Exception.InnerException);
25+
args.SetObserved();
26+
};
27+
28+
AppDomain.CurrentDomain.UnhandledException += (_, args) => ExceptionLogger.Log(args.ExceptionObject as Exception);
3429

3530
ExceptionLogger.OnExceptionRecorded += exception =>
3631
{

0 commit comments

Comments
 (0)