@@ -131,11 +131,45 @@ public Control SettingControl
131
131
=> IsExpanded
132
132
? _settingControl
133
133
??= HasSettingControl
134
- ? ( ( ISettingProvider ) PluginPair . Plugin ) . CreateSettingPanel ( )
134
+ ? TryCreateSettingPanel ( PluginPair )
135
135
: null
136
136
: null ;
137
137
private ImageSource _image = ImageLoader . MissingImage ;
138
138
139
+ private static readonly Thickness SettingPanelMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelMargin" ) ;
140
+ private static readonly Thickness SettingPanelItemTopBottomMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelItemTopBottomMargin" ) ;
141
+ private static Control TryCreateSettingPanel ( PluginPair pair )
142
+ {
143
+ try
144
+ {
145
+ // We can safely cast here as we already check this in HasSettingControl
146
+ return ( ( ISettingProvider ) pair . Plugin ) . CreateSettingPanel ( ) ;
147
+ }
148
+ catch ( System . Exception e )
149
+ {
150
+ var errorMsg = $ "Error creating setting panel for plugin { pair . Metadata } \n { e . Message } ";
151
+ var grid = new Grid ( )
152
+ {
153
+ Margin = SettingPanelMargin
154
+ } ;
155
+ var textBox = new TextBox
156
+ {
157
+ Text = errorMsg ,
158
+ IsReadOnly = true ,
159
+ HorizontalAlignment = HorizontalAlignment . Stretch ,
160
+ VerticalAlignment = VerticalAlignment . Top ,
161
+ TextWrapping = TextWrapping . Wrap ,
162
+ Margin = SettingPanelItemTopBottomMargin
163
+ } ;
164
+ textBox . SetResourceReference ( TextBlock . ForegroundProperty , "Color04B" ) ;
165
+ grid . Children . Add ( textBox ) ;
166
+ return new UserControl
167
+ {
168
+ Content = grid
169
+ } ;
170
+ }
171
+ }
172
+
139
173
public Visibility ActionKeywordsVisibility => PluginPair . Metadata . HideActionKeywordPanel ?
140
174
Visibility . Collapsed : Visibility . Visible ;
141
175
public string InitializeTime => PluginPair . Metadata . InitTime + "ms" ;
0 commit comments