Skip to content

Commit

Permalink
more robust checks
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorBanai committed Nov 7, 2019
1 parent a0efb83 commit f2d1d40
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Analogy.Interfaces/DataTypes/DataTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ public static AnalogyLogMessage Parse(IEnumerable<(AnalogyLogMessagePropertyName
continue;
case AnalogyLogMessagePropertyName.Level:
{
if (Enum.TryParse(propertyValue, true, out AnalogyLogLevel level))
if (Enum.TryParse(propertyValue, true, out AnalogyLogLevel level) &&
Enum.IsDefined(typeof(AnalogyLogLevel), level))
{
m.Level = level;
}
Expand Down Expand Up @@ -303,7 +304,8 @@ public static AnalogyLogMessage Parse(IEnumerable<(AnalogyLogMessagePropertyName
}
case AnalogyLogMessagePropertyName.Class:
{
m.Class = Enum.TryParse(propertyValue, true, out AnalogyLogClass cls)
m.Class = Enum.TryParse(propertyValue, true, out AnalogyLogClass cls) &&
Enum.IsDefined(typeof(AnalogyLogClass), cls)
? cls
: AnalogyLogClass.General;
}
Expand Down

0 comments on commit f2d1d40

Please sign in to comment.