 (extend TestDriver
   driver/IDriver
   {:features (constantly #{:set-timezone})})
+
+
+;; wrap-catch-exceptions
+
+(expect
+  {}
+  ((wrap-catch-exceptions identity) {}))
+
+(expect
+  {:status        :failed
+   :class         java.lang.Exception
+   :error         "Something went wrong"
+   :stacktrace    true
+   :query          {}
+   :expanded-query nil}
+  (-> ((wrap-catch-exceptions (fn [_] (throw (Exception. "Something went wrong")))) {})
+      (update :stacktrace boolean)))
 
 
 ;; pre-add-settings

            [metabase.models.setting :as setting]
            [metabase.test.util :refer [resolve-private-fns]]))

(resolve-private-fns metabase.driver.query-processor post-format-rows pre-add-settings)


(defrecord TestDriver []

         (dissoc response3 :driver)]))))


;; TODO: pre-expand-macros
;; TODO: pre-expand-resolve

;; post-add-row-count-and-status

(expect
  {:row_count      5
   :status         :completed
   :data           {:rows [[1] [1] [1] [1] [1]]}
   :rows_truncated 5}
  ;; NOTE: the default behavior is to treat the query as :rows type aggregation and use :max-results-bare-rows
  ((post-add-row-count-and-status (constantly {:rows [[1] [1] [1] [1] [1]]}))
    {:constraints {:max-results           10
                   :max-results-bare-rows 5}}))

(expect
  {:row_count      5
   :status         :completed
   :data           {:rows [[1] [1] [1] [1] [1]]}}
  ;; when we aren't a :rows query the then we use :max-results for our limit
  ((post-add-row-count-and-status (constantly {:rows [[1] [1] [1] [1] [1]]}))
    {:query       {:aggregation {:aggregation-type :count}}
     :constraints {:max-results           10
                   :max-results-bare-rows 5}}))


;; post-format-rows

(expect
