I think you mean :cljs
instead of :cljc
.
I suspect the main issue here is that new
is a special form that wants a symbol recognizable by the compiler, rather than a runtime variable. You can use ex-info
portably, but if you want to leverage specific error types of the host platform, you might try an approach similar to this:
(defn oob-error
[message]
#?(:clj (new ArrayIndexOutOfBoundsException message)
:cljs (new js/RangeError message))
(throw (oob-error "message"))