<< Back to previous view

[CLJ-292] LazySeq.sval() nests RuntimeExceptions Created: 08/Apr/10  Updated: 08/Dec/10  Resolved: 08/Dec/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.3

Type: Enhancement Priority: Minor
Reporter: Daniel Solano Gómez Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Approval: Ok


When evaluating a LazySeq, if an exception occurs it gets wrapped in a RuntimeException and is thrown. Unfortunately, the logic does not differentiate between a RuntimeException and a checked exception. This has what I believe are two unintended side effects.

  1. If a function throws a RuntimeException, such as an IllegalArgumentException, it gets wrapped in a RuntimeException unnecessarily. So, if I am expecting an IllegalArgumentException (as in a test), I will unexpectedly get a RuntimeException instead.
  2. When evaluating nested lazy sequences, if an error occurs, the root exception is wrapped over and over again as the exception winds its way up the stack. In a recent project, this meant having extremely long stack traces that include a half dozen nested RuntimeExceptions. These just get in the way of getting to the root cause.

Both of these scenarios are illustrated in the attached file.

My proposed solution is fairly simple: Instead of indiscriminately wrapping every exceptions a RuntimeException, simply rethrow any RuntimeException. As a result, any RuntimeException will simply wind its way back up the stack with no wrapping, and checked exceptions will only be wrapped once. This should make debugging Clojure programs slightly easier as the resulting stack trace will not include as much irrelevant information.

Comment by Assembla Importer [ 28/Sep/10 4:56 PM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/292
wrapped_exception.clj - https://www.assembla.com/spaces/clojure/documents/d7u-xuqYir34eneJe5avMc/download/d7u-xuqYir34eneJe5avMc
fix-292.diff - https://www.assembla.com/spaces/clojure/documents/blThXoqYur35a4eJe5afGb/download/blThXoqYur35a4eJe5afGb

Comment by Assembla Importer [ 28/Sep/10 4:56 PM ]

dsg said: [file:blThXoqYur35a4eJe5afGb]: Proposed fix

Generated at Sun Jan 22 16:52:59 CST 2017 using JIRA 4.4#649-r158309.