Permalink
Browse files

Added richer exception message for corrupt jar.

  • Loading branch information...
1 parent c55ecca commit e12fcc8b5a72de3b9bc0fe9c027049be2ce13622 Alexander K. Hudek committed Jun 23, 2012
Showing with 10 additions and 6 deletions.
  1. +10 −6 src/bultitude/core.clj
View
@@ -2,6 +2,7 @@
(:require [clojure.java.io :as io]
[clojure.string :as string])
(:import (java.util.jar JarFile)
+ (java.util.zip ZipException)
(java.io File BufferedReader PushbackReader InputStreamReader)
(clojure.lang DynamicClassLoader)))
@@ -46,12 +47,15 @@
(read-ns-form rdr)))
(defn- namespaces-in-jar [jar]
- (let [jarfile (JarFile. jar)]
- (for [entry (enumeration-seq (.entries jarfile))
- :when (clj? entry)
- :let [ns-form (ns-in-jar-entry jarfile entry)]
- :when ns-form]
- ns-form)))
+ (try
+ (let [jarfile (JarFile. jar)]
+ (for [entry (enumeration-seq (.entries jarfile))
+ :when (clj? entry)
+ :let [ns-form (ns-in-jar-entry jarfile entry)]
+ :when ns-form]
+ ns-form))
+ (catch ZipException e
+ (throw (Exception. (str "jar file corrupt: " jar) e)))))
(defn- split-classpath [classpath]
(.split classpath (System/getProperty "path.separator")))

0 comments on commit e12fcc8

Please sign in to comment.