io-prepl and remote-prepl have asymmetric handling of :exception :val's

Description

Per https://ask.clojure.org/index.php/10429/prepl-does-serialize-exception-thrown-during-serialization

Background: io-prepl produces :val keys in three cases - :ret values, :tap values, and exceptions (marked with :exception true). remote-prepl reads those :val keys. Both io-prepl and remote-prepl allow custom transformation of :val keys via valf. By default io-prepl uses pr-str and remote-prepl uses read-string.

Problem: io-prepl applies valf to :val for :ret and :tap values, but not for exceptions. remote-prepl applies valf for ALL :val's (does not specialize per :exception) - these do not match up. If io-prepl returns :exception data (no valf, so data, not string), then remote-prepl will try to read it as a string and fail, and that read failure is reported instead of the original exception.

Repro:

Error reported here is in read-string on a map (the unexpected data), not the original ArithmeticException:

Alternatives:

1) In io-prepl, use valf on :val for :exception. This ensures a consistent transformation for all :val values, and then remote-prepl will work.
2) In remote-prepl, customize read of :val based on :exception flag (and don't apply valf for those). I think the major downside of this alternative is the caller of io-prepl/remote-prepl don't have any control over transformation of exception :val's.

Environment

None

Assignee

Unassigned

Reporter

Alex Miller

Labels

Approval

Vetted

Priority

Major

Affects versions

Fix versions