Updated to return nulls as opposed to the ex being caught with a meaningful message
This commit is contained in:
@@ -264,17 +264,7 @@ namespace Umbraco.Core.Models
|
||||
/// <returns><see cref="Property"/> Value as an <see cref="object"/></returns>
|
||||
public virtual object GetValue(string propertyTypeAlias)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Properties[propertyTypeAlias].Value;
|
||||
}
|
||||
catch (KeyNotFoundException ex)
|
||||
{
|
||||
var message = string.Format("Cannot find the property with alias '{0}' for the node named '{1}' with id '{2} that uses the document type alias '{3}'",
|
||||
propertyTypeAlias, this.Name, this.Id, this.ContentTypeBase.Alias);
|
||||
|
||||
throw new Exception(message, ex);
|
||||
}
|
||||
return Properties.Contains(propertyTypeAlias) ? Properties[propertyTypeAlias].Value : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -285,18 +275,13 @@ namespace Umbraco.Core.Models
|
||||
/// <returns><see cref="Property"/> Value as a <see cref="TPassType"/></returns>
|
||||
public virtual TPassType GetValue<TPassType>(string propertyTypeAlias)
|
||||
{
|
||||
try
|
||||
if (Properties.Contains(propertyTypeAlias) == false)
|
||||
{
|
||||
var convertAttempt = Properties[propertyTypeAlias].Value.TryConvertTo<TPassType>();
|
||||
return convertAttempt.Success ? convertAttempt.Result : default(TPassType);
|
||||
}
|
||||
catch (KeyNotFoundException ex)
|
||||
{
|
||||
var message = string.Format("Cannot find the property with alias '{0}' for the node named '{1}' with id '{2} that uses the document type alias '{3}'",
|
||||
propertyTypeAlias, this.Name, this.Id, this.ContentTypeBase.Alias);
|
||||
return default(TPassType);
|
||||
}
|
||||
|
||||
throw new Exception(message, ex);
|
||||
}
|
||||
var convertAttempt = Properties[propertyTypeAlias].Value.TryConvertTo<TPassType>();
|
||||
return convertAttempt.Success ? convertAttempt.Result : default(TPassType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user