Custom Error in instantsearch

We are catching the errors in instantsearch using the following code:
search.on(‘error’, function(err){} and displaying the appropriate message. Is there any way to throw custom error in instantsearch and render different messages based on diff errors?

The errors that would be caught by on('error') are JS helper errors (source code). These on their own are Algolia client errors, and can be of the following types: