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