Skip to content

Commit 341b2ed

Browse files
Avoid null exception (#1619)
Return better error info for client/server enum mismatch.
1 parent 73f2c05 commit 341b2ed

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/RestSharp/Extensions/ReflectionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public static bool IsSubclassOfRawGeneric(this Type toCheck, Type generic)
9393
if (enumValueAsUnderlyingType != null && Enum.IsDefined(type, enumValueAsUnderlyingType))
9494
ret = (Enum) Enum.ToObject(type, enumValueAsUnderlyingType);
9595

96+
if (ret == null)
97+
throw new ArgumentOutOfRangeException(value + " undefined for " + type);
9698
return ret;
9799
}
98100
}

0 commit comments

Comments
 (0)