Uploaded image for project: 'Clojure'
  1. CLJ-1293

Support (try .. (catch :default _ ..)) for portable "catch-all"

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects versions: None
    • Fix versions: None
    • Labels:
    • Approval:
      Triaged
    • Patch:
      Code and Test

      Description

      Clojurescript has this to expose the untyped catch, which is equivalent to (catch Throwable _) on java.

      http://dev.clojure.org/jira/browse/CLJS-661

      Proposals

      1) add (catch :default _) to mean (catch Throwable _)
      2) add (catch :default _) to mean (catch Exception _)
      3) add (catch :all _) to mean (catch Throwable _)

      Please see design page for discussion of proposals: http://dev.clojure.org/display/design/Platform+Errors

      Patches

      v001 implements just 1)

      This patch is more permissive than my patch for CLJS: The CLJS patch ensures :default catch blocks occur between non-default catch blocks and finally blocks, if present. This patch just makes (catch :default ...) a synonym for (catch Throwable ...). I wanted to keep the change to the compiler minimum.

      Open Question: Catch Throwable (patch v001 does this) or Exception? Alternatively, a more carefully crafted list of "non-fatal" errors. See Scala's NonFatal pattern extractor: http://www.scala-lang.org/api/current/scala/util/control/NonFatal$.html

      v002 implements 2) + 3)

      This builds on v001, so the same caveat about clause ordering applies.

      v003 implements just 2)

      This builds on v001, so the same caveat about clause ordering applies.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              bbloom Brandon Bloom
            • Votes:
              12 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated: