merkle-open / NitroNetSitecore

NitroNet for Sitecore extends NitroNet with the support for the WCMS Sitecore. It handles all possible presentation scenarios to integrate a handlebars frontend into Sitecore without functional loss.
MIT License
24 stars 9 forks source link

Feature: Better Exception Message if two existing Renderings have the same Name #24

Closed hombreDelPez closed 5 years ago

hombreDelPez commented 6 years ago

Sitecore 9.0.1 ships with new renderings for EXM (e.g. "Footer" or "Header"). Chances are that projects want to create rendering with the same name and run into this exception. We might want to add the possibility to ignore certain rendering paths (e.g. config setting).

Addition: It would be helpful to enrich the exception message with information of which renderings are duplicates. Catch exception and rethrow.

Exception:

Error Rendering View: /Views/Shared/NitroLayout.cshtml: Error while rendering view: '/Views/Shared/NitroLayout.cshtml' (model: 'Sitecore.Mvc.Presentation.RenderingModel, Sitecore.Mvc'). at Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) Inner Exception: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add) at NitroNet.Sitecore.Rendering.SitecoreRenderingRepository.GetAllRenderings() at NitroNet.Sitecore.Rendering.SitecoreRenderingRepository.GetRenderingId(String renderingName) at NitroNet.Sitecore.SitecoreMvcNitroTemplateHandler.RenderComponent(RenderingParameter component, RenderingParameter skin, RenderingParameter dataVariation, Object model, RenderingContext context) at NitroNet.ViewEngine.TemplateHandler.ComponentHelperHandler.Evaluate(Object model, RenderingContext context, IDictionary2 parameters) at lambda_method(Closure , RenderingContext , Object ) at NitroNet.ViewEngine.ViewEngines.VeilViewEngine.VeilView1.Render(T model, RenderingContext context) at NitroNet.ViewEngine.ViewEngines.VeilViewEngine.VeilViewAdapter1.Render(Object model, RenderingContext context) at NitroNet.Sitecore.SitecoreNitroNetViewEngine.SitecoreViewAdapter.Render(Object model, RenderingContext context) at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) at Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer)

hombreDelPez commented 5 years ago

This part

[...]We might want to add the possibility to ignore certain rendering paths (e.g. config setting).[...]

is covered by this pull request: https://github.com/namics/NitroNetSitecore/pull/25

hombreDelPez commented 5 years ago

The exception message now looks like this: [ArgumentException: There exist two renderings with the same name 'accessibilitynavigation' located under '/sitecore/layout/Renderings/Project ABC/Patterns/Molecules/Accessibility Navigation' and '/sitecore/layout/Renderings/Accessibility Navigation']