Clojure

GC Issue 44: non-Exception throwables stay wrapped in InvocationTargetException

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Reported by s-google...@localtoast.org, Jan 14, 2009
What (small set of) steps will reproduce the problem?

Invoke a java method which throws an AssertionError (or any other subclass
of Error), through reflection.

What is the expected output? What do you see instead?

I'd expect to catch the AssertionError object itself (which is the case for
a type-annotated call). Instead, I end up catching an InvocationTargetException

What version are you using?

r1214

Comment 1 by richhickey, Jan 24, 2009
Could you please provide some Clojure code that demonstrates the problem?
Comment 2 by s-google...@localtoast.org, Jan 29, 2009
; method defined through clojure for brevity, any java method which throws a
non-Exception will suffice
user=> (defn throw-error [] (throw (new Error)))
#'user/throw-error

; expected behavior (type annotation creates a direct call)
user=> (let [#^clojure.lang.IFn o throw-error] (.invoke o))
java.lang.Error (NO_SOURCE_FILE:0)

; unexpected behavior, the reflect code has wrapped our Throwable
user=> (let [o throw-error] (.invoke o))
java.lang.reflect.InvocationTargetException (NO_SOURCE_FILE:0)


Comment 3 by richhickey, Feb 23, 2009
fixed - svn 1303 - thank for the report
Status: Fixed
Comment 4 by berlin.brown, Feb 24, 2009
I am getting this error also, is this fixed in the december release:


(defn simple-mkdirs-handler
  "Simple utility to make directories.  Throws error on invalid directory."
  [dirname]
  ;;;;;;;;;;;;;;;;;
  (if (empty? dirname) (throw (Error. "ERR: <mkdirs> Invalid Directory"))
      (let [file (new File dirname)]
        (if (not (.canWrite file))
          (throw (Error. "ERR: <mkdirs> Invalid Directory. Cannot write."))
          (try (.mkdirs file)
               (catch Exception e
                      (throw (Error. (str "ERR: <mkdirs> Invalid Directory. Cannot
mkdir => " 
                                          (.getMessage e))))))))))

Activity

Hide
Assembla Importer added a comment -
Show
Assembla Importer added a comment - Converted from http://www.assembla.com/spaces/clojure/tickets/48

People

  • Assignee:
    Unassigned
    Reporter:
    Anonymous
Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: