Skip to content

Instantly share code, notes, and snippets.

@nha
Last active May 13, 2019 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nha/763ef7f2dd404931809648925cca6e0f to your computer and use it in GitHub Desktop.
Save nha/763ef7f2dd404931809648925cca6e0f to your computer and use it in GitHub Desktop.
presto clj exception bean
;; TO run:
;; - install clj
;; - start a clj REPL with presto: clojure -Sdeps '{:deps {com.facebook.presto/presto-jdbc {:mvn/version "0.219"}}}'
;; - copy-paste this gist content
(ns hello-presto
(:import [java.util Date]
[com.facebook.presto.jdbc.internal.client FailureInfo FailureInfo$FailureException]))
(println "Date bean:" (bean (Date.)))
(println "Exception bean:" (bean (Exception. "something wrong")))
(println "Runtime Exception" (bean (RuntimeException. "somemessage" nil)))
;; using presto with the clojure java.jdbc driver, when a query fails, I get this
;;java.lang.IllegalAccessException: Class clojure.core$bean$fn__6906$fn__6907 can not access a member of class com.facebook.presto.jdbc.internal.client.FailureInfo$FailureException with modifiers "public"
;; Here is a short reproduction
;;
(println "FailureInfo:" (bean (FailureInfo. "sometype"
"somemessage"
nil
[]
[]
nil)))
(println "FailureInfo toException: " (bean (.toException (FailureInfo. "sometype"
"somemessage"
nil
[]
[]
nil))))
;; Error printing return value (IllegalAccessException) at sun.reflect.Reflection/ensureMemberAccess (Reflection.java:102).
;; Class clojure.core$bean$fn__7182$fn__7183 can not access a member of class com.facebook.presto.jdbc.internal.client.FailureInfo$FailureException with modifiers "public"
;; {:cause nil, :class com.facebook.presto.jdbc.internal.client.FailureInfo$FailureException, :localizedMessage "somemessage", :message "somemessage", :stackTrace #object["[Ljava.lang.StackTraceElement;" 0x4b3a45f1 "[Ljava.lang.StackTraceElement;@4b3a45f1"], user=>
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment