1
1
using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Reflection ;
2
4
using System . Runtime . InteropServices ;
3
5
using System . Windows . Forms ;
4
6
using System . Windows . Input ;
@@ -10,6 +12,8 @@ namespace Rubberduck.UI.Command
10
12
[ ComVisible ( false ) ]
11
13
public abstract class CommandBase : ICommand
12
14
{
15
+ private static readonly List < MethodBase > ExceptionTargetSites = new List < MethodBase > ( ) ;
16
+
13
17
protected CommandBase ( ILogger logger )
14
18
{
15
19
_logger = logger ;
@@ -33,12 +37,17 @@ public bool CanExecute(object parameter)
33
37
}
34
38
catch ( Exception exception )
35
39
{
36
- _logger . Fatal ( exception ) ;
40
+ Logger . Fatal ( exception ) ;
41
+
42
+ if ( ! ExceptionTargetSites . Contains ( exception . TargetSite ) )
43
+ {
44
+ ExceptionTargetSites . Add ( exception . TargetSite ) ;
37
45
38
- var messageBox = new MessageBox ( ) ;
39
- messageBox . Show (
40
- RubberduckUI . RubberduckFatalError , RubberduckUI . Rubberduck ,
41
- MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
46
+ var messageBox = new MessageBox ( ) ;
47
+ messageBox . Show (
48
+ RubberduckUI . RubberduckFatalError , RubberduckUI . Rubberduck ,
49
+ MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
50
+ }
42
51
43
52
return false ;
44
53
}
@@ -52,12 +61,17 @@ public void Execute(object parameter)
52
61
}
53
62
catch ( Exception exception )
54
63
{
55
- _logger . Fatal ( exception ) ;
64
+ Logger . Fatal ( exception ) ;
65
+
66
+ if ( ! ExceptionTargetSites . Contains ( exception . TargetSite ) )
67
+ {
68
+ ExceptionTargetSites . Add ( exception . TargetSite ) ;
56
69
57
- var messageBox = new MessageBox ( ) ;
58
- messageBox . Show (
59
- RubberduckUI . RubberduckFatalError , RubberduckUI . Rubberduck ,
60
- MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
70
+ var messageBox = new MessageBox ( ) ;
71
+ messageBox . Show (
72
+ RubberduckUI . RubberduckFatalError , RubberduckUI . Rubberduck ,
73
+ MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
74
+ }
61
75
}
62
76
}
63
77
0 commit comments