mirror of
https://github.com/taoensso/telemere.git
synced 2026-01-06 00:59:50 +00:00
This change will only affect rare advanced users that depend on the return value of `log!` or `event!`. For all other users this will be a non-breaking change. Before this commit: `log!` and `event!` returned true iff signal was allowed. After this commit: `log!` and `event!` now ALWAYS return nil. `log!?` and `event!?` have been added that keep the old behaviour. Motivation: It's pretty rare to use the return value when generating log or event signals. I originally included the return value since it CAN be handy, and I figured it could just be ignored by those that don't need it. But #53 showed that there's a downside I hadn't anticipated - some users may actually depend on / prefer a nil return to prevent accidentally affecting program flow. I think that's a legitimate enough concern to still make a change now before v1 final. Apologies for the nuissance!
32 lines
1.2 KiB
Text
32 lines
1.2 KiB
Text
"Error" signal creator, emphasizing (optional id) + error (Exception, etc.).
|
|
|
|
Default kind: `:error`
|
|
Default level: `:error`
|
|
Returns:
|
|
ALWAYS (unconditionally) returns the given error, so can conveniently be
|
|
wrapped by `throw`: (throw (error! (ex-info ...)), etc.
|
|
|
|
Examples:
|
|
|
|
(throw (error! (ex-info "MyEx" {}))) ; %> {:kind :error, :level :error, :error <MyEx> ...}
|
|
(throw (error! ::my-id (ex-info "MyEx" {}))) ; %> {... :id ::my-id ...}
|
|
(throw
|
|
(error!
|
|
{:let [x "x"] ; Available to `:data` and `:msg`
|
|
:data {:x x}
|
|
:msg ["My message:" x]}
|
|
|
|
(ex-info "MyEx" {}))) ; %> {... :data {x "x"}, :msg_ "My msg: x" ...}
|
|
|
|
Tips:
|
|
|
|
- Test using `with-signal`: (with-signal (error! ...)).
|
|
- Supports the same options [2] as other signals [1].
|
|
|
|
- `error` arg is a platform error (`java.lang.Throwable` or `js/Error`).
|
|
|
|
----------------------------------------------------------------------
|
|
[1] See `help:signal-creators` - (`signal!`, `log!`, `event!`, ...)
|
|
[2] See `help:signal-options` - {:keys [kind level id data ...]}
|
|
[3] See `help:signal-content` - {:keys [kind level id data ...]}
|
|
[4] See `help:signal-filters` - (by ns/kind/id/level, sampling, etc.)
|