failjure
failjure copied to clipboard
Feature request: `when-ok` macro
For the occasions when you only care that the form passes and do not need a value from it, I find myself using when-let-ok?:
(f/when-let-ok? [_ (some-fn-that-returns-a-failure-or-a-value...)]
::woohoo)
I propose to add the macro when-ok:
(defmacro when-ok [form & body]
(when-let-ok? [_# ~form]
~@body))
So we can write:
(f/when-ok (some-fn-that-returns-a-failure-or-a-value...)
::woohoo)
Happy to do a PR for this with tests if you're interested in adding it.
ps. Great library by the way, thank you for your efforts!
Isn't it just combination of when and f/ok??
(when (f/ok? (some-fn-that-returns-a-failure-or-a-value))
::woohoo)
Not exactly, (when (f/ok? ... returns nil on a failure whereas I'd like to return the failure.