Skip to content

Commit

Permalink
studio: better error on bad symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
awb99 committed Apr 30, 2024
1 parent ee4ac75 commit b8c05cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/interact/src/ta/interact/studio.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
[extension :as ext]
[ta.interact.template :as template]))

(defn ok-symbol? [s v]
(when (nil? v)
(throw (ex-info (str "quanta studio start: could not resolve template: " s)
{:template s}))))

(defn add-templates [exts]
(let [template-symbols (ext/get-extensions-for exts :quanta/template concat [] [])
template-vars (map requiring-resolve template-symbols)
_ (doall (map ok-symbol? template-symbols template-vars))
template-vals (map var-get template-vars)]
(doall (map template/add template-vals))))

Expand Down
3 changes: 1 addition & 2 deletions lib/interact/src/ta/interact/template.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
"adds a template to the template-db
templates are used in the browser so traders can add
and configure algos easily."
[{:keys [id algo viz] :as template-spec}]
[{:keys [id algo] :as template-spec}]
(assert id "missing mandatory parameter :id")
(assert algo "missing mandatory parameter :algo")
;(assert viz "missing mandatory parameter :viz")
(swap! db assoc id template-spec))

(defn available-templates
Expand Down

0 comments on commit b8c05cd

Please sign in to comment.