Permalink
Browse files

Initial implementation of improved error handling in GUIControlFactory.

  • Loading branch information...
1 parent 6e94ca7 commit 33934453a2abdab863115606f14145d390203e34 @ajp8164 ajp8164 committed Jan 6, 2012
Showing with 19 additions and 5 deletions.
  1. +19 −5 mediaportal/Core/guilib/GUIControlFactory.cs
@@ -369,12 +369,23 @@ private static object ConvertXmlStringToObject(string valueName, string valueTex
return ParseLayout(valueText);
}
- // much of the above could be changed to use the following, needs time for thorough testing though
- //TypeConverter converter = TypeDescriptor.GetConverter(type);
- TypeConverter converter = convCache.TryGetOrAdd(type, t => TypeDescriptor.GetConverter(t));
- if (converter.CanConvertFrom(typeof (string)))
+ try
{
- return converter.ConvertFromString(null, CultureInfo.InvariantCulture, valueText);
+ // much of the above could be changed to use the following, needs time for thorough testing though
+ //TypeConverter converter = TypeDescriptor.GetConverter(type);
+ TypeConverter converter = convCache.TryGetOrAdd(type, t => TypeDescriptor.GetConverter(t));
+ if (converter.CanConvertFrom(typeof(string)))
+ {
+ return converter.ConvertFromString(null, CultureInfo.InvariantCulture, valueText);
+ }
+ }
+ catch (Exception e)
+ {
+ // Something is wrong with the skin xml for this control.
+ // Log the error but re-throw the exception in order to abort control creation.
+ Log.Info("GUIControlFactory.ConvertXmlStringToObject: failed to convert text to type {0}; value name: '{1}', value text {2}",
+ type.ToString(), valueName, valueText);
+ throw e;
}
return null;
@@ -479,8 +490,11 @@ private static object ConvertXmlStringToObject(string valueName, string valueTex
}
catch (Exception e)
{
+ // Something is wrong with the skin xml for this control.
+ // Log the error but re-throw the exception in order to abort control creation.
Log.Info("GUIControlFactory.Create: {0}\r\n\r\n{1}\r\n\r\n", e.Message, e.StackTrace);
Log.Info("Parent: {0} Id: {1}", dwParentId, control.GetID);
+ throw e;
}
return control;

0 comments on commit 3393445

Please sign in to comment.