summaryrefslogtreecommitdiff
path: root/cljlib-macros.fnl
diff options
context:
space:
mode:
authorAndrey Orst <andreyorst@gmail.com>2020-12-31 09:44:57 +0300
committerAndrey Orst <andreyorst@gmail.com>2020-12-31 09:44:57 +0300
commita2b08f721c28b3b56a802031bc35df6a68b219d8 (patch)
treefb41c48902d552e6e2f4cf104770156239b96375 /cljlib-macros.fnl
parentb414ab62c4e3e299bb3ca1dc04944d428574c1f0 (diff)
fix(macros): fix bug in try, add tests
Diffstat (limited to 'cljlib-macros.fnl')
-rw-r--r--cljlib-macros.fnl9
1 files changed, 3 insertions, 6 deletions
diff --git a/cljlib-macros.fnl b/cljlib-macros.fnl
index 26c80d7..19b0107 100644
--- a/cljlib-macros.fnl
+++ b/cljlib-macros.fnl
@@ -1055,23 +1055,20 @@ clauses when we push body epression."
(add-to-try finally catches try form))
(add-to-try finally catches try form)))
`(match (pcall ,try)
- (true res#) (do ,(. finally 1) res#)
+ (true _#) (do ,(. finally 1) _#)
,(make-catch-clauses catches finally))))
(attach-meta try {:fnl/arglist [:body* :catch-clause* :finally-clause?]
:fnl/docstring "General purpose try/catch/finally macro.
-
-(try expression* catch-clause* finally-clause?)
-
Wraps its body in `pcall` and checks the return value with `match`
macro.
-Catch-clause is written either as (catch symbol body*), thus acting as
+Catch clause is written either as (catch symbol body*), thus acting as
catch-all, or (catch value body*) for catching specific errors. It is
possible to have several `catch` clauses. If no `catch` clauses
specified, an implicit catch-all clause is created.
-Finally-clause is optional, and written as (finally body*). If
+Finally clause is optional, and written as (finally body*). If
present, it must be the last clause in the `try` form, and the only
`finally` clause. Note that `finally` clause is for side effects
only, and runs either after succesful run of `try` body, or after any