diff --git a/lib/algo/src/ta/algo/spec/type/bar_strategy.clj b/lib/algo/src/ta/algo/spec/type/bar_strategy.clj index 598f83a0..52b2edc2 100644 --- a/lib/algo/src/ta/algo/spec/type/bar_strategy.clj +++ b/lib/algo/src/ta/algo/spec/type/bar_strategy.clj @@ -7,6 +7,16 @@ [ta.algo.env.core :refer [get-trailing-bars]] [ta.algo.error-report :refer [save-error-report]])) +(defn create-error [spec ex] + (let [filename (save-error-report (str "run-algo-" (:algo spec)) spec ex)] + (error "run-algo " spec " exception. details: " filename) + (nom/fail ::algo-calc {:message "algo calc exception!" + :location :bar-strategy-algo + :file filename + :spec spec + ;:ds-bars ds-bars ; dataset cannot be sent to the browser. + }))) + (defn run-algo-safe [algo-fn env spec ds-bars] (warn "run-algo-safe: " (:algo spec)) (cond @@ -25,15 +35,8 @@ (try (warn "run-algo-safe else.. fn: " algo-fn) (algo-fn env spec ds-bars) - (catch Exception ex - (let [filename (save-error-report (str "run-algo-" (:algo spec)) spec ex)] - (error "run-algo " spec " exception. details: " filename) - (nom/fail ::algo-calc {:message "algo calc exception!" - :location :bar-strategy-algo - :file filename - :spec spec - ;:ds-bars ds-bars ; dataset cannot be sent to the browser. - })))))) + (catch AssertionError ex (create-error spec ex)) + (catch Exception ex (create-error spec ex))))) (defn create-trailing-bar-loader [{:keys [asset calendar trailing-n] :as spec}] (cond diff --git a/lib/engine/src/ta/engine/javelin/cell.clj b/lib/engine/src/ta/engine/javelin/cell.clj index 44b9a875..b2026a09 100644 --- a/lib/engine/src/ta/engine/javelin/cell.clj +++ b/lib/engine/src/ta/engine/javelin/cell.clj @@ -10,6 +10,8 @@ (warn "calculating formula args: " args) (try (apply formula-fn args) + (catch AssertionError ex + (nom/fail ::error {:message "algo assert failure"})) (catch Exception ex (nom/fail ::error {:message "algo exception"}))))) diff --git a/lib/import/src/ta/db/bars/dynamic/import.clj b/lib/import/src/ta/db/bars/dynamic/import.clj index ac20a6da..ab3561eb 100644 --- a/lib/import/src/ta/db/bars/dynamic/import.clj +++ b/lib/import/src/ta/db/bars/dynamic/import.clj @@ -41,6 +41,10 @@ (nom/fail ::get-bars-safe {:message "import-provider has returned nil." :opts opts :task task}))) + (catch AssertionError ex + (nom/fail ::get-bars-safe {:message "import-provider get-bars has thrown an assertion error" + :opts opts + :task task})) (catch Exception ex (nom/fail ::get-bars-safe {:message "import-provider get-bars has thrown an exception" :opts opts @@ -53,6 +57,9 @@ (info "dynamically received ds-bars! appending to db...") (b/append-bars (:bar-db state) opts bar-ds) (overview/update-range (:overview-db state) opts (:db task))) + (catch AssertionError ex + (error "dynamic-import.append-bars exception! asset: " (:asset opts) "calendar: " (:calendar opts)) + nil) (catch Exception ex (error "dynamic-import.append-bars exception! asset: " (:asset opts) "calendar: " (:calendar opts)) nil)))