Escape pattern queries and wrap sendquery in try-catch.