Permalink
Browse files

Mantis 3790. Improved error handling during control creation for impr…

…oved debugging of skin xml problems.
  • Loading branch information...
1 parent 4ddf7ba commit 923b6650962aea4a8958075b2897066394582cd0 @ajp8164 ajp8164 committed Jul 19, 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
+ {
+ // 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)
{
- return converter.ConvertFromString(null, CultureInfo.InvariantCulture, valueText);
+ // 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;

2 comments on commit 923b665

Member

jamesonuk replied Aug 1, 2012

should this be using Log.Error rather than Log.Info ?

Member

Marvman replied Aug 19, 2012

Error for sure

Please sign in to comment.