Skip to content

Commit

Permalink
Format qualified keys properly
Browse files Browse the repository at this point in the history
This is very important for clojure.spec.
  • Loading branch information
hlship committed Jul 1, 2016
1 parent ef938dd commit b3301ab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.27 - 1 Jul 2016

Qualified keys in exception maps are now printed properly.

## 0.1.26 - 15 Apr 2016

To get around Clojure 1.8 deep linking, `io.aviso.repl/install-pretty-exceptions` now reloads clojure.test
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:plugins [[lein-codox "0.9.3"]]
:profiles {:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
:dev {:dependencies [[criterium "0.4.3"]]}}
:dev {:dependencies [[criterium "0.4.4"]]}}
;; Part of release is currently manual; copy target/docs to the AvisoNovate/docs/pretty folder
:aliases {"release" ["do"
"clean,"
Expand Down
14 changes: 12 additions & 2 deletions src/io/aviso/exception.clj
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,10 @@

(defn- update-keys [m f]
"Builds a map where f has been applied to each key in m."
(into {} (map (fn [[k v]] [(f k) v]) m)))
(reduce-kv (fn [m k v]
(assoc m (f k) v))
{}
m))

(defn- write-stack-trace
[writer stack-trace modern?]
Expand Down Expand Up @@ -483,6 +486,13 @@
[value]
(pp/write value :stream nil :length (or *print-length* 10) :dispatch exception-dispatch))

(defn- qualified-name [x]
(let [x-ns (namespace x)
x-name (name x)]
(if x-ns
(str x-ns "/" x-name)
x-name)))

(defn write-exception*
"Contains the main logic for [[write-exception]], which simply expands
the exception (via [[analyze-exception]]) before invoking this function.
Expand Down Expand Up @@ -512,7 +522,7 @@
(str exception-font class-name reset-font)
(str message-font message reset-font))
(when show-properties?
(let [properties (update-keys (:properties e) name)
(let [properties (update-keys (:properties e) qualified-name)
prop-keys (keys properties)
;; Allow for the width of the exception class name, and some extra
;; indentation.
Expand Down
2 changes: 1 addition & 1 deletion test/demo.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns demo
(:use [io.aviso ansi binary exception repl]
[clojure test pprint])
[clojure test pprint repl])
(:require [clojure.java.io :as io]
[criterium.core :as c])
(:import (java.sql SQLException)))
Expand Down

0 comments on commit b3301ab

Please sign in to comment.