[spec] Add extra map argument to clojure.core/assert and clojure.spec/assert (like with ex-info)

Description

It's a common requirement to provide extra info about the context of the assertion. For instance one might want to include values of local or dynamic bindings into the assert report, or use `clojure.spec/assert` to leverage structured errors with specs outside of testing environments.

With clojure.core/assert one can splice extra data into formated message but with clojure.spec/assert there is no such feature. The message argument to clojure's assert was added in CLJ-774, and it was acknowledged there that the mechanism is not ideal. One notable benefit of passing reports as data is that editors can handle those gracefully in case of large data.

This proposal is related to but has a broader scope. With an extra map one can pass any value (not just locals), and there is no danger of inadvertently flooding the REPL with large locals.

Environment

None

Activity

Show:
Alex Miller
August 13, 2017, 6:41 PM

Can you start this with a use case for what you are trying to do where this would be useful? The title here is a solution but we find it is best to start with a problem, consider alternatives, and choose a solution.

Vitalie Spinu
August 13, 2017, 7:44 PM

EDITED: Moved motivation into the issue's "Description".

Alex Miller
August 14, 2017, 12:56 PM

Rewriting the ticket from this perspective would be a good start.

Vitalie Spinu
August 14, 2017, 1:35 PM

I would be happy to rewrite, but Jira doesn't allow editing the description.

Alex Miller
August 14, 2017, 1:58 PM

Sorry about that! I've given you edit rights.

Assignee

Unassigned

Reporter

Vitalie Spinu

Labels

Approval

Triaged

Patch

None

Affects versions

Priority

Major
Configure