Proper Exception handling

This commit is contained in:
Shannon
2017-03-23 12:15:14 +11:00
parent d5c9639170
commit e7a540e717
2 changed files with 10 additions and 8 deletions

View File

@@ -438,14 +438,16 @@ namespace Umbraco.Web.PublishedCache.XmlPublishedCache
contentType = getPublishedContentType(PublishedItemType.Content, docTypeAlias);
}
catch (Exception e)
catch (InvalidOperationException e)
{
if (e.TargetSite.Name == "CreatePublishedContentType")
{
content.Instance.RefreshContentFromDatabase();
throw new Exception(string.Format("The content cache failed to find a content type with alias \"{0}\". This usually indicates that the content cache is corrupt; the content cache has been rebuilt in an attempt to self-fix the issue.", docTypeAlias));
}
throw;
content.Instance.RefreshContentFromDatabase();
throw new InvalidOperationException(
string.Format("{0}. This usually indicates that the content cache is corrupt; the content cache has been rebuilt in an attempt to self-fix the issue.",
//keep the original message but don't use this as an inner exception because we want the above message to be displayed, if we use the inner exception
//we can keep the stack trace but the header message will be the original message and the one we really want to display will be hidden below the fold.
e.Message));
}
properties = new Dictionary<string, IPublishedProperty>(StringComparer.OrdinalIgnoreCase);