Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 73 lines (56 sloc) 3.013 kb
5087577 @mmcgrana Update README and project.clj.
authored
1 # clj-stacktrace
2
3 A library for creating more readable stacktraces in Clojure programs.
fe381f9 @mmcgrana Leiningen build scheme, updated README.
authored
4
5 For example, to print a nice stack trace in a REPL:
6
7 => (use 'clj-stacktrace.repl)
8 => ("foo")
013b593 @mmcgrana Update Readme to show actual stacktrace for Clojure 1.2
authored
9 java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)
10 Compiler.java:5440 clojure.lang.Compiler.eval
11 Compiler.java:5391 clojure.lang.Compiler.eval
12 core.clj:2382 clojure.core/eval
13 main.clj:183 clojure.main/repl[fn]
14 main.clj:204 clojure.main/repl[fn]
15 main.clj:204 clojure.main/repl
16 RestFn.java:422 clojure.lang.RestFn.invoke
17 main.clj:262 clojure.main/repl-opt
18 main.clj:355 clojure.main/main
19 RestFn.java:398 clojure.lang.RestFn.invoke
20 Var.java:361 clojure.lang.Var.invoke
21 AFn.java:159 clojure.lang.AFn.applyToHelper
22 Var.java:482 clojure.lang.Var.applyTo
23 main.java:37 clojure.main.main
24 Caused by: java.lang.String cannot be cast to clojure.lang.IFn
25 NO_SOURCE_FILE:2 user/eval100
26 Compiler.java:5424 clojure.lang.Compiler.eval
27
fe381f9 @mmcgrana Leiningen build scheme, updated README.
authored
28
29 In stack traces printed by `pst`:
30
31 * Java methods are described with the usual `name.space.ClassName.methodName` convention and Clojure functions with their own `name.space/function-name` convention.
32 * Anonymous clojure functions are denoted by adding an `[fn]` to their enclosing, named function.
33 * "Caused by" cascades are shown as in regular java stack traces.
34 * Elements are vertically aligned for better readability.
35 * Printing is directed to `*out*`.
36
37 If you want to direct the printing to somewhere other than `*out*`, either use `pst-on` to specify the output location or `pst-str` to capture the printing as a string.
38
39 The library also offers an API for programatically 'parsing' exceptions. This API is used internal for `pst` and can be used to e.g. improve development tools. Try for example:
40
2e3db37 @technomancy Update instructions to use try/catch in init.clj. Fixes #6
technomancy authored
41 ```clj
eafad37 @technomancy Release 0.2.4.
technomancy authored
42 (use 'clj-stacktrace.core)
2e3db37 @technomancy Update instructions to use try/catch in init.clj. Fixes #6
technomancy authored
43 (try
44 ("nofn")
45 (catch Exception e
46 (parse-exception e)))
47 ```
fe381f9 @mmcgrana Leiningen build scheme, updated README.
authored
48
5277a5d @technomancy Instructions for Leiningen 2.
technomancy authored
49 ## Leiningen
50
6ca09a2 @technomancy Release 0.2.7 with an NPE fix.
technomancy authored
51 If you use Leiningen, you can install clj-stacktrace on a user-wide
52 basis. Just add the following to `~/.lein/profiles.clj`:
5277a5d @technomancy Instructions for Leiningen 2.
technomancy authored
53
54 ```clj
794f5f4 @Hatnik Update library version in README to the latest: 0.2.8
Hatnik authored
55 {:user {:dependencies [[clj-stacktrace "0.2.8"]]
5277a5d @technomancy Instructions for Leiningen 2.
technomancy authored
56 :injections [(let [orig (ns-resolve (doto 'clojure.stacktrace require)
57 'print-cause-trace)
58 new (ns-resolve (doto 'clj-stacktrace.repl require)
59 'pst)]
f286703 Replace @ in README with deref
Reed Lipman authored
60 (alter-var-root orig (constantly (deref new))))]}}
5277a5d @technomancy Instructions for Leiningen 2.
technomancy authored
61 ```
62
6ca09a2 @technomancy Release 0.2.7 with an NPE fix.
technomancy authored
63 The `:injections` clause replaces the built-in stack trace printing
64 with enhanced clj-stacktrace version; you can leave it out if you plan
65 on invoking clj-stacktrace functions directly or are using tools which
66 are already clj-stacktrace-aware.
3774f0f @technomancy Switch to clj-stacktrace-test hook and document :repl-options
technomancy authored
67
5087577 @mmcgrana Update README and project.clj.
authored
68 ## License
fe381f9 @mmcgrana Leiningen build scheme, updated README.
authored
69
6ca09a2 @technomancy Release 0.2.7 with an NPE fix.
technomancy authored
70 Copyright © 2009-2013 Mark McGranaghan and contributors.
fb11426 @technomancy Release 0.2.5.
technomancy authored
71
72 Released under an MIT license.
Something went wrong with that request. Please try again.