Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Determine if Find index is connected or 401 in code

$
0
0

My developer index timed out and this presented a great oppertunity for me to pop out friendly errors instead of a 401 in case we run into a network glitch in production

I'm trying to find a way to determine of the index invalid or unreachable  (we are using on-prem and there is a chance we can't access the index) so that I can present a friendly error instead of a system 401 error.   

The example code has a function to determine of the search in configured

private bool SearchIndexIsConfigured(EPiServer.Find.Configuration configuration)
        {
            return (!configuration.ServiceUrl.IsNullOrEmpty()&& !configuration.ServiceUrl.Contains("YOUR_URI")&& !configuration.DefaultIndex.IsNullOrEmpty()&& !configuration.DefaultIndex.Equals("YOUR_INDEX"));
        }

This works great, but it doesn't account for if the service is running or a 401.  Is there anything I can do to check for this?  The only thing I can see is the settings is the query settings times out.  For now I can play with that, but I'm certain there is a more graceful way to handle this.

Thanks!


Viewing all articles
Browse latest Browse all 9076

Trending Articles