@@ -14,10 +14,6 @@ namespace MADE.Diagnostics
14
14
/// </summary>
15
15
public class AppDiagnostics : IAppDiagnostics
16
16
{
17
- #if __ANDROID__
18
- private UncaughtExceptionHandler javaExceptionHandler ;
19
- #endif
20
-
21
17
/// <summary>
22
18
/// Initializes a new instance of the <see cref="AppDiagnostics"/> class.
23
19
/// </summary>
@@ -63,17 +59,9 @@ public async Task StartRecordingDiagnosticsAsync()
63
59
64
60
#if WINDOWS_UWP
65
61
Windows . UI . Xaml . Application . Current . UnhandledException += this . OnAppUnhandledException ;
66
- #elif NETSTANDARD2_0 || __ANDROID__ || __IOS__
62
+ #elif NETSTANDARD2_0
67
63
AppDomain . CurrentDomain . UnhandledException += this . OnAppUnhandledException ;
68
64
#endif
69
-
70
- #if __ANDROID__
71
- Android . Runtime . AndroidEnvironment . UnhandledExceptionRaiser += this . OnAndroidAppUnhandledException ;
72
-
73
- this . javaExceptionHandler = new UncaughtExceptionHandler ( this . OnJavaUncaughtException ) ;
74
- Java . Lang . Thread . DefaultUncaughtExceptionHandler = this . javaExceptionHandler ;
75
- #endif
76
-
77
65
TaskScheduler . UnobservedTaskException += this . OnTaskUnobservedException ;
78
66
79
67
await Task . CompletedTask ;
@@ -91,14 +79,9 @@ public void StopRecordingDiagnostics()
91
79
92
80
#if WINDOWS_UWP
93
81
Windows . UI . Xaml . Application . Current . UnhandledException -= this . OnAppUnhandledException ;
94
- #elif NETSTANDARD2_0 || __ANDROID__ || __IOS__
82
+ #elif NETSTANDARD2_0
95
83
AppDomain . CurrentDomain . UnhandledException -= this . OnAppUnhandledException ;
96
84
#endif
97
-
98
- #if __ANDROID__
99
- Android . Runtime . AndroidEnvironment . UnhandledExceptionRaiser -= this . OnAndroidAppUnhandledException ;
100
- #endif
101
-
102
85
TaskScheduler . UnobservedTaskException -= this . OnTaskUnobservedException ;
103
86
104
87
this . IsRecordingDiagnostics = false ;
@@ -128,7 +111,7 @@ private void OnAppUnhandledException(object sender, Windows.UI.Xaml.UnhandledExc
128
111
? $ "An unhandled exception was thrown. Error: { args . Exception } "
129
112
: "An unhandled exception was thrown. Error: No exception information was available." ) ;
130
113
}
131
- #elif NETSTANDARD2_0 || __ANDROID__ || __IOS__
114
+ #elif NETSTANDARD2_0
132
115
private void OnAppUnhandledException ( object sender , UnhandledExceptionEventArgs args )
133
116
{
134
117
if ( args . IsTerminating )
@@ -149,29 +132,5 @@ private void OnAppUnhandledException(object sender, UnhandledExceptionEventArgs
149
132
this . ExceptionObserved ? . Invoke ( this , new ExceptionObservedEventArgs ( correlationId , ex ) ) ;
150
133
}
151
134
#endif
152
-
153
- #if __ANDROID__
154
- private void OnAndroidAppUnhandledException ( object sender , Android . Runtime . RaiseThrowableEventArgs args )
155
- {
156
- args . Handled = true ;
157
-
158
- var correlationId = Guid . NewGuid ( ) ;
159
-
160
- this . EventLogger . WriteCritical ( $ "An unhandled exception was thrown. Correlation ID: { correlationId } . Error: { args . Exception } .") ;
161
- this . ExceptionObserved ? . Invoke ( this , new ExceptionObservedEventArgs ( correlationId , args . Exception ) ) ;
162
- }
163
-
164
- private void OnJavaUncaughtException ( Exception ex )
165
- {
166
- var correlationId = Guid . NewGuid ( ) ;
167
-
168
- this . EventLogger . WriteCritical (
169
- ex != null
170
- ? $ "An unhandled exception was thrown. Correlation ID: { correlationId } . Error: { ex } ."
171
- : $ "An unhandled exception was thrown. Correlation ID: { correlationId } . Error: No exception information was available.") ;
172
-
173
- this . ExceptionObserved ? . Invoke ( this , new ExceptionObservedEventArgs ( correlationId , ex ) ) ;
174
- }
175
- #endif
176
135
}
177
136
}
0 commit comments