Gravatar for

Question by David Masters, Jul 4, 2017 4:32 PM

Handling rendering exceptions in Coveo components (web forms)

We frequently get yellow screens of death which are coming from Coveo components (such as CoveoSearchBox).

I want these components to fall over gracefully if for whatever reason Coveo isn't working so that the site still functions, even if the search isn't working.

I'm used to Sitecore MVC where we'd normally just add exception handling as a pipeline, but it seems you can't do that with WebForms.

I have tried to create a copy of the User Controls and catch exceptions thrown in the RenderControl. This does prevent a yellow screen, but it results in half of the markup being sent in the response writer breaking the page on the front end.

Do you have any advice on how I can easily make all of the coveo controls fail gracefully?

Currently I'm thinking I will have to re-work them so that no server code gets executed in the Render method - i.e. move the execution of the Model.GetJavaScriptInitializationOptions() method into the page load storing the result into a property which can then be referenced in the markup.

Gravatar for

Comment by Jean-François L'Heureux, Jul 4, 2017 6:19 PM

Which version of Coveo for Sitecore are you using? Recent versions of Coveo UI components have health checks and fail gracefully.

1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Jul 5, 2017 1:54 PM

Hi David,

This version of Coveo for Sitecore have health check and component settings validation built-in the UI components. You can see it in the ascx files:

<coveoui:ErrorSummary runat="server" />
<coveoui:WhenConfigured runat="server">

The `coveoui:WhenConfigured` will return `false` for its `Visible` property if the health check is not passing or if the component settings are invalid. This hides the components and catches the exceptions during the health check.

The health check validates that the context Sitecore search index is successfully initialized.

If the Sitecore search index is successfully initialized but the underlying Coveo index has problems after the initialization, the JS UI will handle the error by displaying the "Oops" message on the client-side.

Can you share some exception examples you encountered? Please include the context of those errors as well.



Gravatar for

Comment by David Masters, Jul 6, 2017 12:56 PM

Hi Jeff,

We have seen errors come from lines like this in the actual markup:

CoveoForSitecore.componentsOptions = <%= Model.GetJavaScriptInitializationOptions() %>;

Which sometimes produces errors such as:

Precondition failed:The parameter 'pIndex' must not be null
Parameter name: pIndex

This can happen when our free trial expires, or more worryingly after a deployment to one of our Azure environments. In the case of the latter, it seems to resolve itself after a few minutes.

My concern though, is that if for some reason Coveo is unavailable I obviously don't want the entire website to be down (which is would be due to the search box being in the header).

Gravatar for

Comment by David Masters, Jul 7, 2017 1:00 PM

Are we doing something wrong? I would have thought that if we trying to connect to an expired organisation that the components should just fail gracefully with the mechanisms you have you described?

Ask a question