capture trace when query created & append on err