From e79cca92f1f15a5650f2fa971f5ec5ac834ea8eb Mon Sep 17 00:00:00 2001
From: Cam Saul <cammsaul@gmail.com>
Date: Fri, 12 Apr 2019 19:16:55 -0700
Subject: [PATCH] Indentation improvements

---
 .../middleware/catch_exceptions.clj           | 45 ++++++++++---------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/src/metabase/query_processor/middleware/catch_exceptions.clj b/src/metabase/query_processor/middleware/catch_exceptions.clj
index 5dcba95f170..58fb63a0f18 100644
--- a/src/metabase/query_processor/middleware/catch_exceptions.clj
+++ b/src/metabase/query_processor/middleware/catch_exceptions.clj
@@ -32,29 +32,34 @@
   "Return a nice error message to explain the schema validation error."
   [error]
   (cond
-    (instance? NamedError error)      (let [nested-error (.error ^NamedError error)]
-                                        ;; recurse until we find the innermost nested named error, which is the reason
-                                        ;; we actually failed
-                                        (if (instance? NamedError nested-error)
-                                          (recur nested-error)
-                                          (or (when (map? nested-error)
-                                                (explain-schema-validation-error nested-error))
-                                              (.name ^NamedError error))))
-    (map? error)                      (first (for [e     (vals error)
-                                                   :when (or (instance? NamedError e)
-                                                             (instance? ValidationError e))
-                                                   :let  [explanation (explain-schema-validation-error e)]
-                                                   :when explanation]
-                                               explanation))
+    (instance? NamedError error)
+    (let [nested-error (.error ^NamedError error)]
+      ;; recurse until we find the innermost nested named error, which is the reason
+      ;; we actually failed
+      (if (instance? NamedError nested-error)
+        (recur nested-error)
+        (or (when (map? nested-error)
+              (explain-schema-validation-error nested-error))
+            (.name ^NamedError error))))
+
+    (map? error)
+    (first (for [e     (vals error)
+                 :when (or (instance? NamedError e)
+                           (instance? ValidationError e))
+                 :let  [explanation (explain-schema-validation-error e)]
+                 :when explanation]
+             explanation))
+
     ;; When an exception is thrown, a ValidationError comes back like
     ;;    (throws? ("foreign-keys is not supported by this driver." 10))
     ;; Extract the message if applicable
-    (instance? ValidationError error) (let [explanation (schema.utils/validation-error-explain error)]
-                                        (or (when (list? explanation)
-                                              (let [[reason [msg]] explanation]
-                                                (when (= reason 'throws?)
-                                                  msg)))
-                                            explanation))))
+    (instance? ValidationError error)
+    (let [explanation (schema.utils/validation-error-explain error)]
+      (or (when (list? explanation)
+            (let [[reason [msg]] explanation]
+              (when (= reason 'throws?)
+                msg)))
+          explanation))))
 
 (defn catch-exceptions
   "Middleware for catching exceptions thrown by the query processor and returning them in a normal format."
-- 
GitLab