11using  System ; 
2+ using  System . Collections . Generic ; 
3+ using  System . Reflection ; 
24using  System . Runtime . InteropServices ; 
35using  System . Windows . Forms ; 
46using  System . Windows . Input ; 
@@ -10,6 +12,8 @@ namespace Rubberduck.UI.Command
1012    [ ComVisible ( false ) ] 
1113    public  abstract  class  CommandBase  :  ICommand 
1214    { 
15+         private  static readonly  List < MethodBase >  ExceptionTargetSites  =  new  List < MethodBase > ( ) ; 
16+ 
1317        protected  CommandBase ( ILogger  logger ) 
1418        { 
1519            _logger  =  logger ; 
@@ -33,12 +37,17 @@ public bool CanExecute(object parameter)
3337            } 
3438            catch  ( Exception  exception ) 
3539            { 
36-                 _logger . Fatal ( exception ) ; 
40+                 Logger . Fatal ( exception ) ; 
41+ 
42+                 if  ( ! ExceptionTargetSites . Contains ( exception . TargetSite ) ) 
43+                 { 
44+                     ExceptionTargetSites . Add ( exception . TargetSite ) ; 
3745
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+                 } 
4251
4352                return  false ; 
4453            } 
@@ -52,12 +61,17 @@ public void Execute(object parameter)
5261            } 
5362            catch  ( Exception  exception ) 
5463            { 
55-                 _logger . Fatal ( exception ) ; 
64+                 Logger . Fatal ( exception ) ; 
65+ 
66+                 if  ( ! ExceptionTargetSites . Contains ( exception . TargetSite ) ) 
67+                 { 
68+                     ExceptionTargetSites . Add ( exception . TargetSite ) ; 
5669
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+                 } 
6175            } 
6276        } 
6377
0 commit comments