Skip to content

Commit 6ef8a4a

Browse files
committed
Try to load other variables if an exception is thrown during loading. Handle loading exceptions per watch entry and display error in tooltip of type.
1 parent d276051 commit 6ef8a4a

File tree

7 files changed

+104
-24
lines changed

7 files changed

+104
-24
lines changed

Visual_Studio_2017/GraphicalDebugging/GeometryWatchControl.xaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,24 @@
113113
<DataTemplate>
114114
<TextBlock Text="{Binding Type}">
115115
<TextBlock.ToolTip>
116-
<TextBlock Text="{Binding Type}" TextWrapping="Wrap" />
116+
<TextBlock Text="{Binding TypeOrError}" TextWrapping="Wrap">
117+
<TextBlock.Style>
118+
<Style TargetType="{x:Type TextBlock}">
119+
<Style.Triggers>
120+
<DataTrigger Binding="{Binding IsError}" Value="true">
121+
<Setter Property="Foreground" Value="{x:Static Brushes.Red}" />
122+
</DataTrigger>
123+
</Style.Triggers>
124+
</Style>
125+
</TextBlock.Style>
126+
</TextBlock>
117127
</TextBlock.ToolTip>
118128
<TextBlock.Style>
119129
<Style TargetType="{x:Type TextBlock}">
120130
<Style.Triggers>
131+
<DataTrigger Binding="{Binding IsError}" Value="true">
132+
<Setter Property="Foreground" Value="{x:Static Brushes.Red}" />
133+
</DataTrigger>
121134
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">
122135
<Setter Property="ToolTip.Visibility" Value="Collapsed" />
123136
</Trigger>

Visual_Studio_2017/GraphicalDebugging/GeometryWatchControl.xaml.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,21 @@ private void UpdateItems(bool load, int modified_index = -1)
311311
{
312312
if (Geometries[i].Drawable == null && names[i] != null && names[i] != "")
313313
{
314-
ExpressionDrawer.IDrawable d = null;
315-
Geometry.Traits t = null;
316-
ExpressionLoader.Load(names[i], ExpressionLoader.OnlyGeometries, out t, out d);
317-
if (t == null) // Traits has to be defined for Geometry
318-
d = null;
319-
Geometries[i].Drawable = d;
320-
Geometries[i].Traits = t;
314+
try
315+
{
316+
ExpressionDrawer.IDrawable d = null;
317+
Geometry.Traits t = null;
318+
ExpressionLoader.Load(names[i], ExpressionLoader.OnlyGeometries, out t, out d);
319+
if (t == null) // Traits has to be defined for Geometry
320+
d = null;
321+
Geometries[i].Drawable = d;
322+
Geometries[i].Traits = t;
323+
Geometries[i].Error = null;
324+
}
325+
catch (Exception e)
326+
{
327+
Geometries[i].Error = e.Message;
328+
}
321329
}
322330
drawables[i] = Geometries[i].Drawable;
323331
traits[i] = Geometries[i].Traits;

Visual_Studio_2017/GraphicalDebugging/GraphicalWatchControl.xaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,24 @@
9797
<DataTemplate>
9898
<TextBlock Text="{Binding Type}" TextWrapping="Wrap">
9999
<TextBlock.ToolTip>
100-
<TextBlock Text="{Binding Type}" TextWrapping="Wrap" />
100+
<TextBlock Text="{Binding TypeOrError}" TextWrapping="Wrap">
101+
<TextBlock.Style>
102+
<Style TargetType="{x:Type TextBlock}">
103+
<Style.Triggers>
104+
<DataTrigger Binding="{Binding IsError}" Value="true">
105+
<Setter Property="Foreground" Value="{x:Static Brushes.Red}" />
106+
</DataTrigger>
107+
</Style.Triggers>
108+
</Style>
109+
</TextBlock.Style>
110+
</TextBlock>
101111
</TextBlock.ToolTip>
102112
<TextBlock.Style>
103113
<Style TargetType="{x:Type TextBlock}">
104114
<Style.Triggers>
115+
<DataTrigger Binding="{Binding IsError}" Value="true">
116+
<Setter Property="Foreground" Value="{x:Static Brushes.Red}" />
117+
</DataTrigger>
105118
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">
106119
<Setter Property="ToolTip.Visibility" Value="Collapsed" />
107120
</Trigger>

Visual_Studio_2017/GraphicalDebugging/GraphicalWatchControl.xaml.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,14 @@ private void UpdateItem(bool load, int index)
250250

251251
if (!ExpressionDrawer.Draw(graphics, variable.Drawable, variable.Traits, settings, m_colors))
252252
bmp = null;
253+
254+
variable.Error = null;
253255
}
254-
catch (Exception)
256+
catch (Exception e)
255257
{
256258
bmp = null;
259+
260+
variable.Error = e.Message;
257261
}
258262

259263
type = ExpressionLoader.TypeFromExpressions(expressions);
@@ -262,7 +266,9 @@ private void UpdateItem(bool load, int index)
262266
}
263267

264268
// set new row
265-
ResetAt(new GraphicalItem(variable.Drawable, variable.Traits, variable.Name, bmp, type), index);
269+
ResetAt(new GraphicalItem(variable.Drawable, variable.Traits,
270+
variable.Name, bmp, type, variable.Error),
271+
index);
266272
}
267273

268274
private void imageItem_Copy(object sender, RoutedEventArgs e)

Visual_Studio_2017/GraphicalDebugging/PlotWatchControl.xaml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,24 @@
113113
<DataTemplate>
114114
<TextBlock Text="{Binding Type}">
115115
<TextBlock.ToolTip>
116-
<TextBlock Text="{Binding Type}" TextWrapping="Wrap" />
116+
<TextBlock Text="{Binding TypeOrError}" TextWrapping="Wrap">
117+
<TextBlock.Style>
118+
<Style TargetType="{x:Type TextBlock}">
119+
<Style.Triggers>
120+
<DataTrigger Binding="{Binding IsError}" Value="true">
121+
<Setter Property="Foreground" Value="{x:Static Brushes.Red}" />
122+
</DataTrigger>
123+
</Style.Triggers>
124+
</Style>
125+
</TextBlock.Style>
126+
</TextBlock>
117127
</TextBlock.ToolTip>
118128
<TextBlock.Style>
119129
<Style TargetType="{x:Type TextBlock}">
120130
<Style.Triggers>
131+
<DataTrigger Binding="{Binding IsError}" Value="true">
132+
<Setter Property="Foreground" Value="{x:Static Brushes.Red}" />
133+
</DataTrigger>
121134
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">
122135
<Setter Property="ToolTip.Visibility" Value="Collapsed" />
123136
</Trigger>

Visual_Studio_2017/GraphicalDebugging/PlotWatchControl.xaml.cs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,19 +319,27 @@ private void UpdateItems(bool load, int modified_index = -1)
319319
{
320320
if (Plots[i].Drawable == null && names[i] != null && names[i] != "")
321321
{
322-
ExpressionDrawer.IDrawable d = null;
323-
Geometry.Traits t = null;
324-
ExpressionLoader.Load(names[i], ExpressionLoader.OnlyMultiPoints, out t, out d);
325-
if (d != null)
322+
try
326323
{
327-
if (t != null)
328-
t = new Geometry.Traits(t.Dimension); // force cartesian
329-
d = new ExpressionDrawer.PointsContainer(d as ExpressionDrawer.MultiPoint);
324+
ExpressionDrawer.IDrawable d = null;
325+
Geometry.Traits t = null;
326+
ExpressionLoader.Load(names[i], ExpressionLoader.OnlyMultiPoints, out t, out d);
327+
if (d != null)
328+
{
329+
if (t != null)
330+
t = new Geometry.Traits(t.Dimension); // force cartesian
331+
d = new ExpressionDrawer.PointsContainer(d as ExpressionDrawer.MultiPoint);
332+
}
333+
else
334+
ExpressionLoader.Load(names[i], ExpressionLoader.OnlyValuesContainers, out t, out d);
335+
Plots[i].Drawable = d;
336+
Plots[i].Traits = t;
337+
Plots[i].Error = null;
338+
}
339+
catch (Exception e)
340+
{
341+
Plots[i].Error = e.Message;
330342
}
331-
else
332-
ExpressionLoader.Load(names[i], ExpressionLoader.OnlyValuesContainers, out t, out d);
333-
Plots[i].Drawable = d;
334-
Plots[i].Traits = t;
335343
}
336344
drawables[i] = Plots[i].Drawable;
337345
traits[i] = Plots[i].Traits;

Visual_Studio_2017/GraphicalDebugging/VariableItem.cs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public VariableItem(string name, string type)
2323
{
2424
Name = name;
2525
Type = type;
26+
Error = null;
2627
}
2728

2829
protected string name;
@@ -45,6 +46,23 @@ public string Type
4546
get { return this.type; }
4647
set { this.type = value; }
4748
}
49+
50+
protected string error;
51+
public string Error
52+
{
53+
get { return this.error; }
54+
set { this.error = value; }
55+
}
56+
57+
public bool IsError
58+
{
59+
get { return Error != null && Error != ""; }
60+
}
61+
62+
public string TypeOrError
63+
{
64+
get { return IsError ? Error : Type; }
65+
}
4866
}
4967

5068
class DrawableItem : VariableItem
@@ -83,9 +101,10 @@ public GraphicalItem()
83101

84102
public GraphicalItem(ExpressionDrawer.IDrawable drawable,
85103
Geometry.Traits traits,
86-
string name, System.Drawing.Bitmap bmp, string type)
104+
string name, System.Drawing.Bitmap bmp, string type, string error)
87105
: base(drawable, traits, name, type)
88106
{
107+
Error = error;
89108
Bmp = bmp;
90109
}
91110

0 commit comments

Comments
 (0)