Skip to content
Snippets Groups Projects
Commit 72da119e authored by Lewis Liu's avatar Lewis Liu
Browse files

Fixed error display for pulse preview endpoint

parent 08af9045
Branches
Tags
No related merge requests found
......@@ -86,10 +86,10 @@
[id]
(let [card (Card id)]
(read-check Database (:database (:dataset_query card)))
(let [data (:data (qp/dataset-query (:dataset_query card) {:executed_by *current-user-id*}))]
(let [result (qp/dataset-query (:dataset_query card) {:executed_by *current-user-id*})]
{:status 200, :body (html [:html [:body {:style "margin: 0;"} (binding [render/*include-title* true
render/*include-buttons* true]
(render/render-pulse-card card data))]])})))
(render/render-pulse-card card result))]])})))
(defendpoint GET "/preview_card_info/:id"
"Get JSON object containing HTML rendering of a `Card` with ID and other information."
......
......@@ -398,8 +398,10 @@
(defn render-pulse-card
"Render a single CARD for a `Pulse`. DATA is the `:data` from QP results (I think)."
[card data]
[card result]
(try
(if (:error result) (throw (Exception. "Card has errors")))
(let [data (:data result)]
[:a {:href (card-href card)
:target "_blank"
:style (style section-style
......@@ -428,7 +430,7 @@
[:div {:style (style font-style
{:color "#F9D45C"
:font-weight 700})}
"We were unable to display this card." [:br] "Please view this card in Metabase."])]
"We were unable to display this card." [:br] "Please view this card in Metabase."])])
(catch Throwable e
(log/warn "Pulse card render error:" e)
[:div {:style (style font-style
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment