Skip to content

Commit

Permalink
nrepl: introduce get-printed-stack-trace to helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Sep 26, 2016
1 parent 7b4b257 commit 51dd41d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/nrepl/dirac/nrepl/helpers.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(ns dirac.nrepl.helpers
(:require [dirac.nrepl.version :refer [version]])
(:import (java.util UUID)))
(:import (java.util UUID)
(java.io StringWriter PrintWriter)))

(defmacro with-err-output [& body]
`(binding [*out* *err*]
Expand All @@ -15,3 +16,12 @@

(defn generate-uuid []
(str (UUID/randomUUID)))

(defn get-printed-stack-trace []
(try
(throw (Throwable. ""))
(catch Throwable e
(let [string-writer (StringWriter.)
writer (PrintWriter. string-writer)]
(.printStackTrace e writer)
(str string-writer)))))

0 comments on commit 51dd41d

Please sign in to comment.