better location info in error, #33
This commit is contained in:
parent
f4b10bc46c
commit
ef34e84e59
2 changed files with 17 additions and 14 deletions
|
|
@ -5,18 +5,22 @@
|
|||
<script crossorigin src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>
|
||||
<script src="../js/scittle.reagent.js" type="application/javascript"></script>
|
||||
<script type="application/x-scittle">
|
||||
(require '[reagent.core :as r]
|
||||
'[reagent.dom :as rdom])
|
||||
(require '[sci.core :as sci])
|
||||
(defn try-load-string [s]
|
||||
(try
|
||||
(js/scittle.core.eval_string s)
|
||||
(catch ^:sci/error js/Error e
|
||||
(run! println (-> (sci/stacktrace e) (sci/format-stacktrace))))))
|
||||
|
||||
(def state (r/atom {:clicks 0}))
|
||||
(try-load-string "
|
||||
(defn f []
|
||||
(subs nil 42))
|
||||
|
||||
(defn my-component []
|
||||
[:div
|
||||
[:p "Clicks: " (:clicks @state)]
|
||||
[:p [:button {:on-click #(do (print :foo) (println :dude) (prn (with-out-str (prn :foo))) (swap! state update :clicks inc))}
|
||||
"Click me!"]]])
|
||||
(defn g []
|
||||
(f))
|
||||
|
||||
(rdom/render [my-component] (.getElementById js/document "app"))
|
||||
(g)
|
||||
")
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue