Skip to content
Snippets Groups Projects
Commit f83fbcae authored by Cam Saül's avatar Cam Saül
Browse files

Fix bug in edit segments API endpoint :wrench:

parent 4ffcc006
No related branches found
No related tags found
No related merge requests found
(ns metabase.api.common.internal
"Internal functions used by `metabase.api.common`."
(:require [clojure.tools.logging :as log]
(:require [clojure.java.jdbc :as jdbc]
[clojure.string :as s]
[medley.core :as m]
[swiss.arrows :refer :all]
[metabase.util :as u]))
[metabase.util :as u])
(:import java.sql.SQLException))
;;; # DEFENDPOINT HELPER FUNCTIONS + MACROS
......@@ -232,10 +234,12 @@
status-code message
;; Otherwise it's a 500. Return a body that includes exception & filtered stacktrace for debugging purposes
:else (let [stacktrace (u/filtered-stacktrace e)]
(log/debug message "\n" (u/pprint-to-str stacktrace))
(assoc other-info
:message message
:stacktrace stacktrace)))}))))
(merge (assoc other-info
:message message
:stacktrace stacktrace)
(when (instance? SQLException e)
{:sql-exception-chain (s/split (with-out-str (jdbc/print-sql-exception-chain e))
#"\s*\n\s*")}))))}))))
(defmacro catch-api-exceptions
"Execute BODY, and if an exception is thrown, return the appropriate HTTP response."
......
......@@ -112,7 +112,7 @@
(integer? user-id)
(string? revision_message)]}
;; update the segment itself
(db/update! Segment id
(db/update-non-nil-keys! Segment id
:name name
:description description
:caveats caveats
......
......@@ -16,7 +16,7 @@
(java.net Socket
InetSocketAddress
InetAddress)
java.sql.Timestamp
(java.sql SQLException Timestamp)
(java.util Calendar TimeZone)
javax.xml.bind.DatatypeConverter
org.joda.time.format.DateTimeFormatter))
......@@ -560,7 +560,7 @@
(fn [& args]
(try
(apply f args)
(catch java.sql.SQLException e
(catch SQLException e
(log/error (format-color 'red "%s\n%s\n%s"
exception-message
(with-out-str (jdbc/print-sql-exception-chain e))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment