clojure-dev

Issues: https://clojure.atlassian.net/browse/CLJ | Guide: https://insideclojure.org/2015/05/01/contributing-clojure/
dpsutton 2020-07-09T20:52:03.353500Z

would there be any interest in a patch to add an assert that allowed for data in an ex-info rather than just a message string?

ghadi 2020-07-09T21:04:30.353800Z

I don't follow

dpsutton 2020-07-09T21:09:24.355800Z

(assert (every? symbol? gs) (str "Invalid predicate expression " gs)) from core match. vs (assert (every? symbol? gs) {:pattern p :predicate-expression gs})

ghadi 2020-07-09T21:09:57.356100Z

gotta start with a problem

ghadi 2020-07-09T21:10:18.356500Z

I have no idea what the context is

ghadi 2020-07-09T21:11:29.357900Z

is there a problem in ex-info in core or something with core match?

dpsutton 2020-07-09T21:12:33.358800Z

no. but asserts used for constraint violations are convenient and feel right. But when the constraint is violated you can only give a string message rather than the richer data structure that ex-info allows

ghadi 2020-07-09T21:14:43.359700Z

hate to be a broken record, but I'm still lost

ghadi 2020-07-09T21:15:00.360300Z

I'm guessing that there is some stringy exception somewhere that you want to have richer data?

dpsutton 2020-07-09T21:15:04.360500Z

understood. i'll put more clarity into it later

1
ghadi 2020-07-09T21:15:06.360700Z

donde? core.match?

dpsutton 2020-07-09T21:16:18.362300Z

used that for a public example. in our codebase, we assert colls/only , that a collection only had a single value. like the results of a query that you expect to return a single value. Would be nice if we could include the clause that violated the constraint in our message rather than just pr-str'ing it

ghadi 2020-07-09T21:16:48.362900Z

oh you want assert itself to throw some rich data

dpsutton 2020-07-09T21:16:56.363200Z

right

bronsa 2020-07-09T21:17:28.363300Z

ex-info is an Exception, assert throws an Error

favila 2020-07-09T21:19:03.364100Z

the assert could throw an AssertionError subclass that implements IExceptionInfo

bronsa 2020-07-09T21:20:25.364500Z

but Errors are not supposed to be caught

bronsa 2020-07-09T21:20:38.364800Z

An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch

bronsa 2020-07-09T21:21:08.365400Z

so having a payload doesn't seem that worthy if you're not supposed to be able to access it

dpsutton 2020-07-09T21:21:50.366100Z

our use case is that our logging infra displays that stuff nicely in addition to the stacktrace. versus just a string

dpsutton 2020-07-09T21:23:35.366700Z

its a simple macro away. that's a good consideration i hadn't thought of. thanks @bronsa