mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-12 17:38:13 +08:00
better exception message
This commit is contained in:
9
res/App.Designer.cs
generated
9
res/App.Designer.cs
generated
@@ -113,6 +113,15 @@ namespace YaeAchievement.res {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Network error ({0}: {1}).
|
||||||
|
/// </summary>
|
||||||
|
internal static string ExceptionNetwork {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ExceptionNetwork", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Export to:
|
/// Looks up a localized string similar to Export to:
|
||||||
///[0] Cocogoat (https://cocogoat.work/achievement, Default)
|
///[0] Cocogoat (https://cocogoat.work/achievement, Default)
|
||||||
|
|||||||
@@ -134,4 +134,7 @@ Input a number (0-5): </value>
|
|||||||
<data name="VcRuntimeInstalling" xml:space="preserve">
|
<data name="VcRuntimeInstalling" xml:space="preserve">
|
||||||
<value>Installing Visual C++ Redistributable...</value>
|
<value>Installing Visual C++ Redistributable...</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ExceptionNetwork" xml:space="preserve">
|
||||||
|
<value>Network error ({0}: {1})</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -128,4 +128,7 @@
|
|||||||
<data name="VcRuntimeInstalling" xml:space="preserve">
|
<data name="VcRuntimeInstalling" xml:space="preserve">
|
||||||
<value>正在安装 Visual C++ Redistributable...</value>
|
<value>正在安装 Visual C++ Redistributable...</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ExceptionNetwork" xml:space="preserve">
|
||||||
|
<value>网络错误,请检查网络后重试 ({0}: {1})</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
16
src/Utils.cs
16
src/Utils.cs
@@ -3,6 +3,7 @@ using System.Diagnostics;
|
|||||||
using System.IO.Pipes;
|
using System.IO.Pipes;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http.Headers;
|
using System.Net.Http.Headers;
|
||||||
|
using System.Net.Sockets;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using YaeAchievement.AppCenterSDK;
|
using YaeAchievement.AppCenterSDK;
|
||||||
@@ -149,14 +150,23 @@ public static class Utils {
|
|||||||
public static void InstallExceptionHook() {
|
public static void InstallExceptionHook() {
|
||||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => {
|
AppDomain.CurrentDomain.UnhandledException += (_, e) => {
|
||||||
var ex = e.ExceptionObject;
|
var ex = e.ExceptionObject;
|
||||||
if (ex is ApplicationException exception) {
|
switch (ex) {
|
||||||
Console.WriteLine(exception.Message);
|
case ApplicationException ex1:
|
||||||
} else {
|
Console.WriteLine(ex1.Message);
|
||||||
|
break;
|
||||||
|
case SocketException ex2:
|
||||||
|
Console.WriteLine(App.ExceptionNetwork, nameof(SocketException), ex2.Message);
|
||||||
|
break;
|
||||||
|
case HttpRequestException ex3:
|
||||||
|
Console.WriteLine(App.ExceptionNetwork, nameof(HttpRequestException), ex3.Message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
Console.WriteLine(ex.ToString());
|
Console.WriteLine(ex.ToString());
|
||||||
Console.WriteLine(App.UploadError);
|
Console.WriteLine(App.UploadError);
|
||||||
AppCenter.TrackCrash((Exception) e.ExceptionObject);
|
AppCenter.TrackCrash((Exception) e.ExceptionObject);
|
||||||
AppCenter.Upload();
|
AppCenter.Upload();
|
||||||
Environment.Exit(-1);
|
Environment.Exit(-1);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user