How can I hide uncaught exceptions from being displayed on a production environment? Fx an external data source breaks down, and the following is displayed in my macro:
Error loading Razor Script MyRazorMacro.cshtml
Yes, I could catch the exception, but what to do in case of a parse error?
I of course have "umbracoDebugMode" disabled. Do I really need to implement my own IMacroEngine, or am I missing a setting?
Hi. Razor macros are by their nature compiled on the first usage, so actually a partucalar error may be caused not only with a runtime exception but also with failed compilation. In the latter case I suspect that there's no at least a simple method to hide such an error besides just carefully testing your macro syntax before deployment to the production. As for usual runtime errors I think it's possible just to use conventional methods of error interception like trivial try/catch blocks and so on.
Thanks for your answer. The umbraco.MacroEngines.RazorMacroEngine which executes Razor macros has hardcoded the error text in case of a compilation or runtine error. So there's actually no way to prevent this text other than reimplementing the RazorMacroEngine. Shame..
Hide uncaught exceptions in razor macros
Hello
How can I hide uncaught exceptions from being displayed on a production environment? Fx an external data source breaks down, and the following is displayed in my macro:
Yes, I could catch the exception, but what to do in case of a parse error?
I of course have "umbracoDebugMode" disabled. Do I really need to implement my own IMacroEngine, or am I missing a setting?
/Andreas
Hi. Razor macros are by their nature compiled on the first usage, so actually a partucalar error may be caused not only with a runtime exception but also with failed compilation. In the latter case I suspect that there's no at least a simple method to hide such an error besides just carefully testing your macro syntax before deployment to the production. As for usual runtime errors I think it's possible just to use conventional methods of error interception like trivial try/catch blocks and so on.
Hello Rodion
Thanks for your answer. The umbraco.MacroEngines.RazorMacroEngine which executes Razor macros has hardcoded the error text in case of a compilation or runtine error. So there's actually no way to prevent this text other than reimplementing the RazorMacroEngine. Shame..
Niels is working on the macro engine currently afaiu, perhaps vote for this http://umbraco.codeplex.com/workitem/30617
Great :)
Also see this topic for a way to hide the errors right now and a discussion of why I would not recommend it: http://our.umbraco.org/forum/developers/razor/26059-Switch-razor-error-and-red-box-off
You could also implement your own IHttpModule, and on that implementation add your own Filter stream. In that filter stream remove the
text/html so that it is not sent to the client. It is a not so desired solution, but...
Cheers
is working on a reply...