Reputation: 1021
We have a Sitecore site that's using Glass.Mapper. We also have a simple two step workflow, "Draft > Ready for publish" on all items. There are global items, which are promos that can be placed on pages. Authors create promos, then create pages and place the promos on the pages.
If a page is published but a promo hasn't been published, the page returns this error: Constructor on type 'OurSite.Sitecore.Models.IPromo' not found.
Since the scenario of authors failing to publish new promos is a real one, I would like to prevent this error from happening, so that the page just renders without the promo. Thoughts?
Upvotes: 0
Views: 475
Reputation: 1155
Another option would be to validate the datasource of components in the getRenderer pipeline. Marek has blogged about this with a solid solution:
http://www.skillcore.net/sitecore/sitecore-automated-validation-of-mvc-rendering-datasource
This also handles the scenario where components without datasource (ie. item was deleted) break the page in PageEditor.
That being said I also believe that in addition you should have a proper exception strategy as well. The link Jim Noellsch posted is a good one. I recall this one from Charlie Turano to be a solid one as well:
http://www.hhogdev.com/blog/2015/june/mvc-rendering-exception-handler.aspx
Upvotes: 1
Reputation: 714
Assuming IPromo
is an interface, convert it to a class model Promo
. If this is an MVC solution, you could also override the OnException
method to quietly suppress missing content.
Upvotes: 0