Skip to content

Commit 3bf131e

Browse files
committed
Gracefully handle invalid value enums.
1 parent 28ea57b commit 3bf131e

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Build/CommonAssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
//
1616
// You can specify all the values or you can default the Revision and Build Numbers
1717
// by using the '*' as shown below:
18-
[assembly: AssemblyVersion("1.1.5")]
19-
[assembly: AssemblyFileVersion("1.1.5")]
18+
[assembly: AssemblyVersion("1.1.6")]
19+
[assembly: AssemblyFileVersion("1.1.6")]

Griddly.Mvc/GriddlyColumn.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public virtual HtmlString RenderValue(object value, bool encode = true)
4545
else
4646
value = value.ToString();
4747

48+
if (value == null)
49+
return null;
4850
if (value is HtmlString)
4951
return (HtmlString)value;
5052
else if (encode)

Griddly.Mvc/InternalExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ internal static HtmlString GetHtmlView(string value, bool turnUrlsIntoLinks = fa
8080

8181
internal static string ToStringDescription(Enum value)
8282
{
83-
if (value == null || !Enum.IsDefined(value.GetType(), value))
83+
if (value == null)
8484
return null;
85+
else if (!Enum.IsDefined(value.GetType(), value))
86+
return "[Undefined " + value.GetType().Name + " Value: " + value + "]";
8587

8688
return GetEnumDescription(value.GetType().GetField(value.ToString()));
8789
}

0 commit comments

Comments
 (0)