mirror of https://github.com/status-im/timbre.git
Allow `fspy` to capture freq for exception-throwing bodies
This commit is contained in:
parent
37f4d35b07
commit
545c278394
|
@ -51,10 +51,11 @@
|
||||||
`(if-not *fdata*
|
`(if-not *fdata*
|
||||||
(do ~@body)
|
(do ~@body)
|
||||||
(let [name# ~name
|
(let [name# ~name
|
||||||
result# (do ~@body)]
|
result# (try (do ~@body) (catch Throwable t# {::throwable t#}))
|
||||||
(swap! *fdata* #(assoc-in % [name# result#]
|
throwable# (and (map? result#) (::throwable result#))]
|
||||||
(inc (get-in % [name# result#] 0))))
|
(swap! *fdata* #(assoc-in % [name# (or throwable# result#)]
|
||||||
result#))))
|
(inc (get-in % [name# (or throwable# result#)] 0))))
|
||||||
|
(if throwable# (throw throwable#) result#)))))
|
||||||
|
|
||||||
(defmacro f [name & body] `(fspy name ~@body)) ; Alias
|
(defmacro f [name & body] `(fspy name ~@body)) ; Alias
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue