Skip to content

Commit 0fda3d4

Browse files
author
GLOBAL\H245254
committed
Add property name to the FormatException #1452
Added inner exception and string encoding.
1 parent 7a016bb commit 0fda3d4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/RestSharp/Serializers/Xml/XmlDeserializer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ protected virtual object Map(object x, XElement root)
192192
{
193193
prop.SetValue(x, value.ChangeType(asType), null);
194194
}
195-
catch (FormatException)
195+
catch (FormatException ex)
196196
{
197-
throw new FormatException("Format exception while Deserializing Property Name - " + prop.Name);
197+
throw new FormatException(message: $"Couldn't parse the value of '{value}' into the '{prop.Name}'" +
198+
$" property, because it isn't a type of '{prop.PropertyType}'."
199+
, innerException: ex.InnerException);
198200
}
199201
}
200202
else if (type.IsEnum)

0 commit comments

Comments
 (0)