wraped query command state in a try catch