@@ -20,16 +20,55 @@ public static void Handle(Exception ex)
20
20
var targets = ex . TargetSite ;
21
21
var trace = new StackTrace ( ex , true ) ;
22
22
var assembly = targets ? . DeclaringType . Assembly ;
23
+ bool guessed = false ;
23
24
24
- //Filter the main assembly
25
- if ( assembly is not null )
26
- if ( ! UDAWhitelist . IsOnExceptionWhitelist ( assembly ) || UDABlacklist . IsOnExceptionBlacklist ( assembly ) )
25
+ if ( assembly is null )
26
+ {
27
+ guessed = true ;
28
+
29
+ if ( trace . FrameCount == 0 )
30
+ {
31
+ #if DEBUG
32
+ UDAPlugin . Log ? . LogInfo ( $ "Skipping { ex . GetType ( ) } , trace has no frames") ;
33
+ return ;
34
+ #endif
35
+ }
36
+
37
+ foreach ( var item in trace . GetFrames ( ) )
38
+ {
39
+ if ( item . HasMethod ( ) )
40
+ {
41
+ assembly = item . GetMethod ( ) . DeclaringType . Assembly ;
42
+ break ;
43
+ }
44
+ }
45
+
46
+ if ( assembly is null )
27
47
{
28
48
#if DEBUG
29
- UDAPlugin . Log ? . LogInfo ( $ "Skipping { assembly . GetName ( ) . Name } , failed filter ") ;
49
+ UDAPlugin . Log ? . LogInfo ( $ "Skipping { ex . GetType ( ) } , unable to obtain assembly info ") ;
30
50
#endif
51
+
31
52
return ;
32
53
}
54
+ #if DEBUG
55
+ else
56
+ {
57
+
58
+ UDAPlugin . Log ? . LogInfo ( $ "Guessing { ex . GetType ( ) } 's assembly") ;
59
+
60
+ }
61
+ #endif
62
+ }
63
+
64
+ //Filter the main assembly
65
+ if ( ! UDAWhitelist . IsOnExceptionWhitelist ( assembly ) || UDABlacklist . IsOnExceptionBlacklist ( assembly ) )
66
+ {
67
+ #if DEBUG
68
+ UDAPlugin . Log ? . LogInfo ( $ "Skipping { assembly . GetName ( ) . Name } , failed filter") ;
69
+ #endif
70
+ return ;
71
+ }
33
72
34
73
static string Tabs ( int n )
35
74
{
@@ -172,21 +211,19 @@ static void DoHarmonyBlames(StringBuilder sb, ReadOnlyCollection<Patch>? Patches
172
211
sb . AppendLine ( ex . GetType ( ) . ToString ( ) ) ;
173
212
174
213
sb . Append ( "Assembly: " ) ;
175
- if ( assembly is not null )
214
+ sb . Append ( assembly . GetName ( ) . Name ) ;
215
+
216
+ if ( guessed )
176
217
{
177
- sb . AppendLine ( assembly . GetName ( ) . Name ) ;
218
+ sb . Append ( " (Guess)" ) ;
178
219
}
179
- else
180
- {
181
- sb . AppendLine ( "Unknown" ) ;
182
220
183
- }
221
+ sb . AppendLine ( ) ;
184
222
185
- if ( assembly is not null )
186
- if ( UDAPluginMarshal . InfoCache . TryGetValue ( assembly , out PluginInfo info ) )
187
- {
188
- WritePluginInfo ( sb , info , 1 ) ;
189
- }
223
+ if ( UDAPluginMarshal . InfoCache . TryGetValue ( assembly , out PluginInfo info ) )
224
+ {
225
+ WritePluginInfo ( sb , info , 1 ) ;
226
+ }
190
227
191
228
sb . Append ( "Message: " ) ;
192
229
sb . AppendLine ( ex . Message ) ;
0 commit comments