Browse Clojure Foundations for Java Developers

Handling Java Exceptions

Use try/catch/finally for Java interop and wrap errors with ex-info when helpful.

Java exceptions behave the same way in Clojure: they are JVM throwables. The syntax is just different.

1(try
2  (slurp "missing.txt")
3  (catch java.io.FileNotFoundException e
4    (throw (ex-info "File missing" {:path "missing.txt"} e))))

The Clojure pattern that Java developers usually learn next is ex-info + ex-data: wrap a failure with a message and a small data map that callers can inspect. This section focuses on writing exception handling that is explicit, testable, and not scattered across your core logic.

In this section

Revised on Friday, April 24, 2026