|
126 | 126 | (indent writer (- width (.length value)))
|
127 | 127 | (w/write writer prefix value suffix)))
|
128 | 128 |
|
| 129 | +(defn- write-indented |
| 130 | + [writer indent-amount value] |
| 131 | + (loop [lines (str/split-lines value) |
| 132 | + is-first true] |
| 133 | + (when-not (empty? lines) |
| 134 | + (if-not is-first |
| 135 | + (indent writer indent-amount)) |
| 136 | + (w/writeln writer (first lines)) |
| 137 | + (recur (rest lines) false)))) |
| 138 | + |
129 | 139 | (defn- update-keys [m f]
|
130 | 140 | "Builds a map where f has been applied to each key in m."
|
131 | 141 | (into {} (map (fn [[k v]] [(f k) v]) m)))
|
|
138 | 148 | ;; In a degenerate case, a protocol method could be called "invoke" or "doInvoke"; we're ignoring
|
139 | 149 | ;; that possibility here and assuming it's the IFn.invoke() or doInvoke().
|
140 | 150 | all-ids (if (contains? #{"invoke" "doInvoke"} method-name)
|
141 |
| - function-ids |
142 |
| - (-> function-ids vec (conj method-name)))] |
| 151 | + function-ids |
| 152 | + (-> function-ids vec (conj method-name)))] |
143 | 153 | ;; The assumption is that no real namespace or function name will contain underscores (the underscores
|
144 | 154 | ;; are name-mangled dashes).
|
145 | 155 | (->>
|
|
221 | 231 | (justify class-width class)
|
222 | 232 | (w/writeln "." method)))))
|
223 | 233 |
|
224 |
| - |
225 | 234 | (defn- write-property-value [writer value-indent value]
|
226 |
| - (loop [lines (-> value |
227 |
| - (pp/write :stream nil :length (or *print-length* 10)) |
228 |
| - (str/split-lines)) |
229 |
| - is-first true] |
230 |
| - (if (empty? lines) |
231 |
| - nil |
232 |
| - (do |
233 |
| - (if-not is-first |
234 |
| - (indent writer value-indent)) |
235 |
| - (w/writeln writer (first lines)) |
236 |
| - (recur (rest lines) false))))) |
| 235 | + (write-indented writer value-indent |
| 236 | + (pp/write value :stream nil :length (or *print-length* 10)))) |
237 | 237 |
|
238 | 238 | (defn write-exception
|
239 | 239 | "Writes a formatted version of the exception to the writer.
|
|
258 | 258 | message (.getMessage exception)]
|
259 | 259 | (justify writer exception-column-width exception-font (:name e) reset-font)
|
260 | 260 | ;; TODO: Handle no message for the exception specially
|
261 |
| - (w/write writer ":" |
262 |
| - (if message |
263 |
| - (str " " message-font message reset-font) |
264 |
| - "") |
265 |
| - w/endline) |
| 261 | + (w/write writer ":") |
| 262 | + (if-not message |
| 263 | + (w/writeln writer) |
| 264 | + (do |
| 265 | + (w/write writer " ") |
| 266 | + (write-indented writer |
| 267 | + (+ 2 exception-column-width) |
| 268 | + (str message-font message reset-font)))) |
266 | 269 |
|
267 | 270 | (let [properties (update-keys (:properties e) name)
|
268 | 271 | prop-keys (keys properties)
|
269 | 272 | ;; Allow for the width of the exception class name, and some extra
|
270 | 273 | ;; indentation.
|
271 |
| - prop-name-width (+ exception-column-width |
272 |
| - 4 |
273 |
| - (max-length prop-keys))] |
| 274 | + prop-name-width (+ 4 (max-length prop-keys))] |
274 | 275 | (doseq [k (sort prop-keys)]
|
275 | 276 | (justify writer prop-name-width property-font k reset-font)
|
276 | 277 | (w/write writer ": ")
|
|
0 commit comments