Exception when query does not return a range