forked from NickeManarin/ScreenToGif
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
68 lines (54 loc) · 1.81 KB
/
App.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Threading;
using Translator.Util;
namespace Translator;
public partial class App : Application
{
private void App_Startup(object sender, StartupEventArgs e)
{
//Unhandled Exceptions.
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
}
private void App_OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
LogWriter.Log(e.Exception, "On Dispacher Unhandled Exception - Unknown");
try
{
ExceptionDialog.Ok(e.Exception, "ScreenToGif - Translator", "Unhandled exception", e.Exception.Message);
}
catch (Exception ex)
{
LogWriter.Log(ex, "Error while displaying the error.");
//Ignored.
}
e.Handled = true;
}
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
if (e.ExceptionObject is not Exception exception)
return;
LogWriter.Log(exception, "Current Domain Unhandled Exception - Unknown");
try
{
ExceptionDialog.Ok(exception, "ScreenToGif - Translator", "Unhandled exception", exception.Message);
}
catch (Exception)
{
//Ignored.
}
}
public static string Version => ToStringShort(Assembly.GetEntryAssembly()?.GetName().Version) ?? "0.0";
internal static string ToStringShort(Version version)
{
if (version == null)
return null;
var result = $"{version.Major}.{version.Minor}";
if (version.Build > 0)
result += $".{version.Build}";
if (version.Revision > 0)
result += $".{version.Revision}";
return result;
}
}