diff --git a/src/Platform.Xml.Serialization/StringableTypeSerializer.cs b/src/Platform.Xml.Serialization/StringableTypeSerializer.cs index 06052dc..074d6d9 100644 --- a/src/Platform.Xml.Serialization/StringableTypeSerializer.cs +++ b/src/Platform.Xml.Serialization/StringableTypeSerializer.cs @@ -72,12 +72,25 @@ public override string Serialize(object obj, SerializationContext state) /// public override object Deserialize(string value, SerializationContext state) { - if (formatSpecified) - { - return Convert.ChangeType(value, supportedType, formatAttribute.CultureInfo); - } + + try + { + if (formatSpecified) + { + return Convert.ChangeType(value, supportedType, formatAttribute.CultureInfo); + } - return Convert.ChangeType(value, supportedType); + return Convert.ChangeType(value, supportedType); + } + catch(Exception ex) + { + var memberInfo = state.GetCurrentMemberInfo().MemberInfo; + throw new Exception(string.Format("Can't deserialize property {0} of class {1}. Could not convert value '{2}' to type {3}", + memberInfo.Name, + memberInfo.DeclaringType.FullName, + value, + supportedType), ex); + } } } }