   (when-let [delay-ms (calculate-delay throttler keyy)]
     (let [message (format "Too many attempts! You must wait %d seconds before trying again." (int (math/round (/ delay-ms 1000))))]
       (throw (ex-info message {:status-code 400
-                               :errors      {field-name message}}))))
+                               :errors      {exception-field-key message}}))))
   (swap! attempts conj [keyy (System/currentTimeMillis)]))
 
 


(defrecord Throttler [;; Name of the API field/value being checked. Used to generate appropriate API error messages, so they'll be displayed in the
                      ;; right part of the screen
                      ^Keyword field-name
                      ;; [Internal] List of attempt entries. These are pairs of [key timestamp (ms)], e.g. ["cam@metabase.com" 1438045261132]
                      ^Atom    attempts
                      ;; Amount of time to keep an entry in ATTEMPTS before dropping it.


     (require '[metabase.api.common.throttle :as throttle])
     (def email-throttler (throttle/make-throttler :attempts-threshold 10))"
  [exception-field-key & {:as kwargs}]
  (map->Throttler (merge throttler-defaults kwargs {:attempts   (atom '())
                                                    :exception-field-key exception-field-key})))

(defn check
  "Throttle an API call based on values of KEYY. Each call to this function will record KEYY to THROTTLER's internal list;
