Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 70 lines (53 sloc) 2.867 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
42 (use '(clj-stacktrace core))
43 (try
44 ("nofn")
45 (catch Exception e
46 (parse-exception e)))
47 ```
fe381f9 @mmcgrana Leiningen build scheme, updated README.
authored
48
11ac0f9 @technomancy Update instructions to show user-level plugin installation.
technomancy authored
49 If you use Leiningen, you can install clj-stacktrace on a per-user basis:
50
51 $ lein plugin install clj-stacktrace 0.2.3
52
53 Add this to your `~/.lein/init.clj` file:
54
2e3db37 @technomancy Update instructions to use try/catch in init.clj. Fixes #6
technomancy authored
55 ```clj
56 (try (require 'leiningen.hooks.clj-stacktrace-test)
57 (def settings {:repl-options [:init (require 'clj-stacktrace.repl)
58 :caught 'clj-stacktrace.repl/pst+]})
59 (catch java.io.FileNotFoundException _))
60 ```
11ac0f9 @technomancy Update instructions to show user-level plugin installation.
technomancy authored
61
62 The hook will enable clj-stacktrace to be used across all the projects
63 you work on in clojure.test and other things that use the
64 clojure.stacktrace library. The :repl-options settings will cause
65 clj-stacktrace to be used in the repl and swank.
3774f0f @technomancy Switch to clj-stacktrace-test hook and document :repl-options
technomancy authored
66
5087577 @mmcgrana Update README and project.clj.
authored
67 ## License
fe381f9 @mmcgrana Leiningen build scheme, updated README.
authored
68
905b093 @technomancy Update readme with version.
technomancy authored
69 Copyright 2009-2011 Mark McGranaghan and released under an MIT license.
Something went wrong with that request. Please try again.