Error-handling for empty queries