Fork me on GitHub
#reveal
<
2022-02-19
>
sheluchin15:02:33

I'd like to use a sticker to show me https://github.com/fulcrologic/guardrails log errors. They look like this and come up during runtime:

user=> (f 3.2)
ERROR /Users/user/project/src/com/domain/app_ns.clj:12 f's argument list
 -- Spec failed --------------------

  [3.2]
   ^^^

should satisfy

  int?

or

  string?

-- Relevant specs -------

:user/thing:
  (clojure.spec.alpha/or :i clojure.core/int? :s clojure.core/string?)
This https://github.com/fulcrologic/guardrails/blob/920a372e86063a255b5036b4d07303f87024bb9e/src/main/com/fulcrologic/guardrails/core.cljc#L87 is responsible for handling errors and ultimately delegates error printing to utils/report-problem, which just calls (.println message-str). I can't quite figure out how to set up the sticker. I understand that stickers are typically applied to ref types, but is it possible to use with a simple function as a sort of watch? Any tips?

vlaaad18:02:18

It seems there is an option for using tap>

vlaaad18:02:32

And reveal has built in tap-sticker

vlaaad18:02:43

Maybe that's enough?

sheluchin18:02:07

Yes, there is, but I much prefer the string representation show above over the usual Spec error description in data. The tap would be good enough, but I am curious if I can use Reveal to keep an eye out on some formatted string output. As an aside, I'm a new Reveal user. Liking it very much so far. Thanks for the awesome tool!

👍 1
vlaaad18:02:49

Hmm, this library prints to System/err...

vlaaad18:02:59

You'll need to override that...

sheluchin18:02:43

Ah, just to a simple println instead of the interop call with System/err. Okay, this should suffice. Thank you.