[Fixes #6526] Unwrap TargetInvocationException when executing a ShapeAttributeBinding

This commit is contained in:
Sebastien Ros 2016-03-09 15:37:44 -08:00
parent 26e2fe9977
commit aae9f6270e

View File

@ -60,12 +60,18 @@ namespace Orchard.DisplayManagement.Descriptors.ShapeAttributeStrategy {
var output = new HtmlStringWriter();
var arguments = methodInfo.GetParameters()
.Select(parameter => BindParameter(displayContext, parameter, output));
var returnValue = methodInfo.Invoke(serviceInstance, arguments.ToArray());
if (methodInfo.ReturnType != typeof(void)) {
output.Write(CoerceHtmlString(returnValue));
try {
var returnValue = methodInfo.Invoke(serviceInstance, arguments.ToArray());
if (methodInfo.ReturnType != typeof(void)) {
output.Write(CoerceHtmlString(returnValue));
}
return output;
}
catch(TargetInvocationException e) {
// Throwing a TIE here will probably kill the web process
// in Azure. For unknown reasons.
throw e.InnerException;
}
return output;
}
private static IHtmlString CoerceHtmlString(object invoke) {