diff options
author | scgilardi <scgilardi@gmail.com> | 2008-07-06 01:55:51 +0000 |
---|---|---|
committer | scgilardi <scgilardi@gmail.com> | 2008-07-06 01:55:51 +0000 |
commit | 37044c82ac649b1360a036fff7415c1ac305af0f (patch) | |
tree | b37318cb5bcc27f52fb52b52eef5f9e340f564c2 | |
parent | 6c56ff70968f59120e4ec55b471a9ff97b01c747 (diff) |
lib.clj: throw-if tweaks
-rw-r--r-- | lib.clj | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -163,8 +163,7 @@ "Throws an exception with a message if pred is true. Args after pred will be passed along to str to form the message." [pred & args] - (when pred - (throw (Exception.(apply str args))))) + (if pred (throw (Exception.(apply str args))))) (def find-resource) ; forward declaration (def load-resource) ; forward declaration @@ -176,12 +175,10 @@ (let [res (str sym ".clj") rel-path (if in (str in \/ res) res) url (find-resource rel-path)] - (throw-if (not url) - "resource '" rel-path "' not found in classpath") + (throw-if (not url) "resource '" rel-path "' not found in classpath") (load-resource url) - (throw-if (and ns (not (find-ns ns))) - "namespace '" ns "' not found after loading " - "resource '" rel-path "'")) + (throw-if (and ns (not (find-ns ns))) "namespace '" ns "' not found" + " after loading resource '" rel-path "'")) (dosync (commute *libs* conj sym)) (when *verbose* @@ -245,8 +242,7 @@ (instance? URL abs-path) abs-path (instance? URI abs-path) (.toURL abs-path) (string? abs-path) (URL. abs-path))] - (throw-if (not url) - "Cannot coerce " (class abs-path) " to " URL) + (throw-if (not url) "Cannot coerce " (class abs-path) " to " URL) (with-open reader (BufferedReader. (InputStreamReader. |