Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 87 lines (65 sloc) 3.39 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
51 If you use Leiningen, you can install clj-stacktrace on a per-user basis.
52
060708f @desertmonad Fix typos in readme re: lein 2.x instructions.
desertmonad authored
53 For Leiningen 2.x, add the following to `~/.lein/profiles.clj`:
5277a5d @technomancy Instructions for Leiningen 2.
technomancy authored
54
55 ```clj
fb11426 @technomancy Release 0.2.5.
technomancy authored
56 {:user {:dependencies [[clj-stacktrace "0.2.5"]]
5277a5d @technomancy Instructions for Leiningen 2.
technomancy authored
57 :injections [(let [orig (ns-resolve (doto 'clojure.stacktrace require)
58 'print-cause-trace)
59 new (ns-resolve (doto 'clj-stacktrace.repl require)
60 'pst)]
060708f @desertmonad Fix typos in readme re: lein 2.x instructions.
desertmonad authored
61 (alter-var-root orig (constantly @new)))]}}
5277a5d @technomancy Instructions for Leiningen 2.
technomancy authored
62 ```
63
64 For Leiningen 1.x:
11ac0f9 @technomancy Update instructions to show user-level plugin installation.
technomancy authored
65
fb11426 @technomancy Release 0.2.5.
technomancy authored
66 $ lein plugin install clj-stacktrace 0.2.5
11ac0f9 @technomancy Update instructions to show user-level plugin installation.
technomancy authored
67
68 Add this to your `~/.lein/init.clj` file:
69
2e3db37 @technomancy Update instructions to use try/catch in init.clj. Fixes #6
technomancy authored
70 ```clj
71 (try (require 'leiningen.hooks.clj-stacktrace-test)
72 (def settings {:repl-options [:init (require 'clj-stacktrace.repl)
73 :caught 'clj-stacktrace.repl/pst+]})
74 (catch java.io.FileNotFoundException _))
75 ```
11ac0f9 @technomancy Update instructions to show user-level plugin installation.
technomancy authored
76
77 The hook will enable clj-stacktrace to be used across all the projects
78 you work on in clojure.test and other things that use the
eafad37 @technomancy Release 0.2.4.
technomancy authored
79 clojure.stacktrace library. The `:repl-options` settings will cause
80 clj-stacktrace to be used in the repl and swank tasks.
3774f0f @technomancy Switch to clj-stacktrace-test hook and document :repl-options
technomancy authored
81
5087577 @mmcgrana Update README and project.clj.
authored
82 ## License
fe381f9 @mmcgrana Leiningen build scheme, updated README.
authored
83
fb11426 @technomancy Release 0.2.5.
technomancy authored
84 Copyright © 2009-2012 Mark McGranaghan and contributors.
85
86 Released under an MIT license.
Something went wrong with that request. Please try again.