Exception handling for query failure.