Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DesktopClock.Tests/ColorTextConverterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public void Convert_ShowsAColorPickedElsewhereInFull()
[InlineData("#FF000")]
[InlineData("#GG0000")]
[InlineData("Reddish")]
[InlineData("sc#")]
[InlineData("sc#1e999,0,0")]
[InlineData("ContextColor foo 1,2,3")]
public void ConvertBack_RejectsUnreadableText(string text)
{
Assert.Equal(DependencyProperty.UnsetValue, new ColorTextConverter().ConvertBack(text, typeof(Color), null, Culture));
Expand Down
4 changes: 2 additions & 2 deletions DesktopClock/Utilities/ColorTextConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
_typedText = text;
return _typedColor;
}
catch (FormatException)
catch (Exception)
{
// Unreadable text, like a half-typed color, leaves the color as it was and marks the box invalid.
// Unreadable text, like a half-typed color, leaves the color as it was and marks the box invalid. The error isn't always a FormatException: "sc#" gives an InvalidOperationException, and WPF doesn't catch what a converter throws.
return DependencyProperty.UnsetValue;
}
}
Expand Down
Loading