'Set a custom 'no results' message from invalid SPARQL queries

Currently, I'm creating some SPARQL queries, which I am brand new at, for our data analysts. We want them to be able to fill in what they're looking for in custom search boxes that edit the query under the hood. So far I have most working, but I was hoping there is a way to return a custom message if they, say, search for a non-existing table in our dataset. Currently, they get the default "query returned to results" message, but I'd like to change that to something more informative.

I've tried a few loose ideas, but as a newbie myself, it's hard for me to figure out how to implement anything. For instance, I've tried using filters and such to see if I can change a value if the results return a count of 0, but that is not a valid query, unfortunately. I've tried putting the filters in OPTIONAL blocks, creating some BINDs, trying to work with IF statements, etc., but can't seem to get them all working how I'd like.

Does anyone have any experience implementing something like this, or is this idea even possible?? Thanks in advance for any input/tips



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source