aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.clj
diff options
context:
space:
mode:
authorscgilardi <scgilardi@gmail.com>2008-08-14 01:51:58 +0000
committerscgilardi <scgilardi@gmail.com>2008-08-14 01:51:58 +0000
commit860f887a4dbeb6d480904c5667991ab2cdd15ef4 (patch)
tree097e58b695b1949780af714078b3617a0ca8af03 /lib/lib.clj
parent8d7dfc3b132331cfb92f500ded84af5f5c6f740c (diff)
shorten stacktraces from throw-if
Diffstat (limited to 'lib/lib.clj')
-rw-r--r--lib/lib.clj9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/lib.clj b/lib/lib.clj
index 0e07099d..98bd8de8 100644
--- a/lib/lib.clj
+++ b/lib/lib.clj
@@ -181,7 +181,14 @@
"Throws an exception with a message if pred is true. See
java.util.Formatter for format string syntax."
[pred fmt & args]
- (when pred (throw (Exception. (apply format fmt args)))))
+ (when pred
+ (let [message (apply format fmt args)
+ exception (Exception. message)
+ raw-trace (.getStackTrace exception)
+ boring? #(not= (.getMethodName %) "doInvoke")
+ trace (into-array (drop 2 (drop-while boring? raw-trace)))]
+ (.setStackTrace exception trace)
+ (throw exception))))
(def find-resource) ; forward declaration
(def load-resource) ; forward declaration