Makes square more resilent when catalog changes

This commit is contained in:
2023-01-20 08:42:33 -08:00
parent ffbeb3b446
commit d660b3d800

View File

@@ -141,15 +141,23 @@
(defn item->category-name-impl [client item ]
(capture-context->lc
(cond (:item_id (:item_variation_data item))
(de/chain (fetch-catalog-cache client (:item_id (:item_variation_data item)))
(fn [item]
(mu/with-context lc
(item->category-name-impl client item))))
(de/catch (de/chain (fetch-catalog-cache client (:item_id (:item_variation_data item)))
(fn [item]
(mu/with-context lc
(item->category-name-impl client item))))
(fn [e]
(log/error ::couldnt-fetch-variation
:exception e)
"Uncategorized"))
(:category_id (:item_data item))
(de/chain (fetch-catalog-cache client (:category_id (:item_data item)))
:category_data
:name)
(de/catch (de/chain (fetch-catalog-cache client (:category_id (:item_data item)))
:category_data
:name)
(fn [e]
(log/error ::couldnt-fetch-category
:exception e)
"Uncategorized"))
(:item_data item)
"Uncategorized"