A library designed to filter out from Clojure backtraces those frames likely to be of interest to the developer
Clojure backtraces are very hard to read, because they contain many, many 'noise' frames resulting from the internal workings of the Clojure compiler, and relatively few frames from the namespaces the developer is actually working with.
What I'm setting out to do here is to produce tools which allow backtraces to be filtered against a list of 'interesting' namespaces, in order to present a compact trace showing the propagation of the error through the developer's own code, and core libraries that code depends on.
As further goals, I hope
At present, the most useful entry point is
(show-html-backtrace error namespaces)
(show-html-backtrace error)
(show-html-backtrace)
Example usage
(use 'cc.journeyman.errata.core)
;; an error to demonstrate with.
(def error
(try
(/ 1 0)
(catch Exception e e)))
;; you can explicitly pass both exception object and list of namespace names
(show-html-backtrace error ["nrepl.middleware"])
;; `namespaces` defaults to those namespace names registered as interesting,
;; so register one (or more)
(register-interesting-ns! "nrepl.middleware")
(show-html-backtrace error)
;; `error` defaults to the current value of `*e`, so this does exactly the same
;; as `(show-html-backtrace *e)`)`.
(show-html-backtrace)
;; you can also show error in the NREPL terminal.
;; you can explicitly pass both exception object and list of namespace names
(summarise-error error ["nrepl.middleware" "clojure.lang.Number"])
;; `namespaces` defaults to registered interesting namespaces, as before.
(register-interesting-ns! "clojure.lang.Number")
(summarise-error error)
;; `error` defaults to the current value of `*e`, so this does exactly the same
;; as `(summarise-error *e)`)`.
(summarise-error)
;; Finally, for convenience working in the REPL, `serr` is a shortcut for
;; `summarise-error`
(serr)
Copyright © 2021 Simon Brooke
This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version, with the GNU Classpath Exception which is available at https://www.gnu.org/software/classpath/license.html.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close