Use debug query in exception