Created
July 28, 2010 17:55
-
-
Save candera/495545 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn nfe-test [] | |
(try | |
(let [nums (map #(Integer/parseInt %) ["1" "2" "1234123412341234"])] | |
(when (every? #(< 3 %) nums) | |
nums)) | |
(catch NumberFormatException nfe nil))) | |
(nfe-test) ;; throws NumberFormatException, but I would expect it to | |
;; return nil |
fogus
commented
Jul 28, 2010
(defn nfe-test []
(try
(let [nums [(Integer/parseInt "1") (Integer/parseInt "2") (Integer/parseInt "1234123412341234")]]
(when (every? #(< 3 %) (doall nums))
nums))
(catch NumberFormatException nfe 42)
(catch RuntimeException nfe nil)))
(nfe-test)
lazy seq screws that exception up.
Yeah, someone on IRC helped me figure that out. It's highly non-obvious, although it makes sense once I understood it. And it also drives home why checked exceptions totally suck.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment