Skip to content

Commit 0699b4a

Browse files
Copilotbrianrob
andcommitted
Change exception type to ArgumentOutOfRangeException and shorten error message
Co-authored-by: brianrob <[email protected]>
1 parent 1320239 commit 0699b4a

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/PerfView.Tests/StackViewer/StackWindowTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,8 @@ public void TestExportFlameGraphWithInvalidCanvasSize()
874874
var tempFile = Path.GetTempFileName();
875875
try
876876
{
877-
// Attempt to export should throw InvalidOperationException with a meaningful message
878-
var exception = Assert.Throws<InvalidOperationException>(() =>
877+
// Attempt to export should throw ArgumentOutOfRangeException with a meaningful message
878+
var exception = Assert.Throws<ArgumentOutOfRangeException>(() =>
879879
{
880880
FlameGraph.Export(canvas, tempFile);
881881
});

src/PerfView/StackViewer/FlameGraph.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public static void Export(Canvas flameGraphCanvas, string filePath)
8989
// Validate that the canvas has a valid size before attempting to export
9090
if (width <= 0 || height <= 0)
9191
{
92-
throw new InvalidOperationException(
93-
$"Cannot export flame graph: the canvas has an invalid size (width={width}, height={height}). " +
94-
"Please ensure the flame graph is visible and has been rendered before attempting to export.");
92+
throw new ArgumentOutOfRangeException(
93+
"flameGraphCanvas",
94+
$"Canvas has an invalid size (width={width}, height={height}). Please ensure the flame graph is visible and has been rendered before attempting to export.");
9595
}
9696

9797
var renderTargetBitmap = new RenderTargetBitmap(width, height, 96d, 96d, PixelFormats.Default);

src/PerfView/StackViewer/StackWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2772,7 +2772,7 @@ private void DoSaveFlameGraph(object sender, RoutedEventArgs e)
27722772
FlameGraph.Export(FlameGraphCanvas, saveDialog.FileName);
27732773
StatusBar.Log($"Saved flame graph to {saveDialog.FileName}");
27742774
}
2775-
catch (InvalidOperationException ex)
2775+
catch (ArgumentOutOfRangeException ex)
27762776
{
27772777
StatusBar.LogError($"Failed to save flame graph: {ex.Message}");
27782778
}

0 commit comments

Comments
 (0)