File tree Expand file tree Collapse file tree 1 file changed +27
-11
lines changed Expand file tree Collapse file tree 1 file changed +27
-11
lines changed Original file line number Diff line number Diff line change 182182 [env handler]
183183 (update-vals env #(catch-node % handler {:apply-to-condition? true })))
184184
185- (defn with-try-clause-expr
186- [[_ t s expr]]
187- (fn [error]
188- (when (instance? error type)
189- expr)))
185+ #_ (defn with-try-clause-expr
186+ [[_ t s expr]]
187+ (fn [error]
188+ (when (instance? error type)
189+ expr)))
190190
191191; ; '(with-try env (catch type symbol expr))
192192; ; (update-vals env (fn [error] (if (instance? error type)
193193; ; ()
194194; ; ))
195+ #_(defn with-try-expr
196+ [env & clauses]
197+ (let [clauses (for [[catch t s expr] clauses]
198+ (do (assert (= catch 'catch))
199+ [t s expr]))]))
200+
195201(defn with-try-expr
196- [env & clauses]
197- (let [clauses (for [[catch t s expr] clauses]
198- (do (assert (= catch 'catch))
199- [t s expr]))]))
202+ [clauses]
203+ (let [clauses (into {} (for [[c t s expr] clauses]
204+ (do (assert (= c 'catch))
205+ [(resolve t) (eval `(fn [~s] ~expr))]
206+ #_[t s expr])))]
207+ clauses))
200208
201209(defmacro with-try
202210 [env & body]
203- `(try ~env
204- ~@body))
211+ `(with-error-handler
212+ ~env
213+ ~(with-try-expr body)))
214+
215+ (comment
216+ (macroexpand-1 '(with-try {:a " hi" }
217+ (catch Exception e (println e))
218+ (catch Throwable t (println t))))
219+ ;
220+ )
205221
206222(s/defn get-value :- s /Any
207223 [env :- Env
You can’t perform that action at this time.
0 commit comments