Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi Guys,
I can't get the inline macro errors to work in Umbraco v7.7.4. I just get YSOD.
Here is an example partial view CSHTML:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{ throw new Exception("Test") }
debug=false customErrors = Off
Have you updated the setting in umbracoSettings.config?
It should be called MacroErrors
MacroErrors
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/73047-how-do-you-debug-macropartials-errors-error-loading-partial-view-script#comment-234347
Hi Brad
MacroErrors setting in /config/umbracoSettings.config should be set to throw like that:
<MacroErrors>throw</MacroErrors>
Thanks,
Alex
It's set to inline, which is what I want. It's near the end of the project so we're trying to make sure one partialview can't take down the entire homepage. But inline seems to do nothing and I still get the global YSOD.
Here is what it looks like:
If you're trying to prevent a YSOD, why not set it to silent?
silent
Alternatively, can you not update your Macro Partial View to do the relevant null checks to prevent this from happening?
Wrap the code inside the macro to the try catch and handle exceptions.
I mean shouldn't inline work? I'd rather not use silent since the section would completely disappear and someone may not even realize it's missing.
I don't think it's possible to code the partials in a way that anticipates every error possible..
Edit: Just tested, silent doesn't work either.. I get a big YSOD.
I've not actually used that setting before, so I'm not sure why.
I'm not too sure how you're macro is setup, but I would think null checks are possible. Even if they do get excessive. Could you provide an example?
Like Alex mentions above though, at worst you could wrap the code in a try {} catch(){} block and then just put an error message in a p tag
try {} catch(){}
p
Thanks for the idea. I just made some extension methods that wrapped the partial calls with a giant try catch:
public static class HtmlHelperExtension { public static IHtmlString CachedPartial2(this System.Web.Mvc.HtmlHelper htmlHelper, string partialViewName, object model, int cachedSeconds) { try { return htmlHelper.CachedPartial(partialViewName, model, cachedSeconds); } catch (Exception ex) { return MvcHtmlString.Create("<p>There was an error rendering this section: " + partialViewName + "</p><div style='display:none'>" + ex.ToString() + "</div>"); } } public static MvcHtmlString Partial2(this System.Web.Mvc.HtmlHelper htmlHelper, string partialViewName, object model) { try { return htmlHelper.Partial(partialViewName, model); } catch (Exception ex) { return MvcHtmlString.Create("<p>There was an error rendering this section: " + partialViewName + "</p><div style='display:none'>" + ex.ToString() + "</div>"); } } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Cant get inline macroerrors to work on partialview .cshtml
Hi Guys,
I can't get the inline macro errors to work in Umbraco v7.7.4. I just get YSOD.
Here is an example partial view CSHTML:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{ throw new Exception("Test") }
debug=false customErrors = Off
Have you updated the setting in umbracoSettings.config?
It should be called
MacroErrors
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/73047-how-do-you-debug-macropartials-errors-error-loading-partial-view-script#comment-234347
Hi Brad
MacroErrors setting in /config/umbracoSettings.config should be set to throw like that:
Thanks,
Alex
It's set to inline, which is what I want. It's near the end of the project so we're trying to make sure one partialview can't take down the entire homepage. But inline seems to do nothing and I still get the global YSOD.
Here is what it looks like:
If you're trying to prevent a YSOD, why not set it to
silent
?Alternatively, can you not update your Macro Partial View to do the relevant null checks to prevent this from happening?
Wrap the code inside the macro to the try catch and handle exceptions.
I mean shouldn't inline work? I'd rather not use silent since the section would completely disappear and someone may not even realize it's missing.
I don't think it's possible to code the partials in a way that anticipates every error possible..
Edit: Just tested, silent doesn't work either.. I get a big YSOD.
I've not actually used that setting before, so I'm not sure why.
I'm not too sure how you're macro is setup, but I would think null checks are possible. Even if they do get excessive. Could you provide an example?
Like Alex mentions above though, at worst you could wrap the code in a
try {} catch(){}
block and then just put an error message in ap
tagThanks for the idea. I just made some extension methods that wrapped the partial calls with a giant try catch:
is working on a reply...