Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用(try (/ 1 0) (catch Exception e)),但它似乎是多余的。有没有更简单的方法来做到这一点?我使用它的一个例子是我这样做sql/drop-table。该调用是否因为表不存在而失败并不重要。
(try (/ 1 0) (catch Exception e))
sql/drop-table
写一个这样的宏怎么样:
(defmacro swallow-exceptions [& body] `(try ~@body (catch Exception e#))) (swallow-exceptions (/ 1 0)) ; nil
这篇文章中有更复杂的例子。