mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 04:36:12 +02:00
✨ Use proper exceptions on internal db functions
This commit is contained in:
parent
f75da999dc
commit
a9e7ed57d9
1 changed files with 6 additions and 9 deletions
|
@ -237,8 +237,7 @@
|
||||||
(jdbc/get-connection system-or-pool)
|
(jdbc/get-connection system-or-pool)
|
||||||
(if (map? system-or-pool)
|
(if (map? system-or-pool)
|
||||||
(open (::pool system-or-pool))
|
(open (::pool system-or-pool))
|
||||||
(ex/raise :type :internal
|
(throw (IllegalArgumentException. "unable to resolve connection pool")))))
|
||||||
:code :unable-resolve-pool))))
|
|
||||||
|
|
||||||
(defn get-update-count
|
(defn get-update-count
|
||||||
[result]
|
[result]
|
||||||
|
@ -250,9 +249,7 @@
|
||||||
cfg-or-conn
|
cfg-or-conn
|
||||||
(if (map? cfg-or-conn)
|
(if (map? cfg-or-conn)
|
||||||
(get-connection (::conn cfg-or-conn))
|
(get-connection (::conn cfg-or-conn))
|
||||||
(ex/raise :type :internal
|
(throw (IllegalArgumentException. "unable to resolve connection")))))
|
||||||
:code :unable-resolve-connection
|
|
||||||
:hint "expected conn or system map"))))
|
|
||||||
|
|
||||||
(defn connection-map?
|
(defn connection-map?
|
||||||
"Check if the provided value is a map like data structure that
|
"Check if the provided value is a map like data structure that
|
||||||
|
@ -260,15 +257,15 @@
|
||||||
[o]
|
[o]
|
||||||
(and (map? o) (connection? (::conn o))))
|
(and (map? o) (connection? (::conn o))))
|
||||||
|
|
||||||
(defn- get-connectable
|
(defn get-connectable
|
||||||
|
"Resolve to a connection or connection pool instance; if it is not
|
||||||
|
possible, raises an exception"
|
||||||
[o]
|
[o]
|
||||||
(cond
|
(cond
|
||||||
(connection? o) o
|
(connection? o) o
|
||||||
(pool? o) o
|
(pool? o) o
|
||||||
(map? o) (get-connectable (or (::conn o) (::pool o)))
|
(map? o) (get-connectable (or (::conn o) (::pool o)))
|
||||||
:else (ex/raise :type :internal
|
:else (throw (IllegalArgumentException. "unable to resolve connectable"))))
|
||||||
:code :unable-resolve-connectable
|
|
||||||
:hint "expected conn, pool or system")))
|
|
||||||
|
|
||||||
(def ^:private params-mapping
|
(def ^:private params-mapping
|
||||||
{::return-keys? :return-keys
|
{::return-keys? :return-keys
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue