Fork me on GitHub
#cljs-dev
<
2020-11-20
>
juhoteperi09:11:30

I'm trying to show easy to understand error to a library users about moved function. Is creating a macro with same name as the function, and throwing :cljs/analysis-error at all a good idea?

(defn- source-info [env]
  (when (:line env)
    {:file (ana-api/current-file)
     :line (:line env)
     :column (:column env)}))

(defmacro render
  [& body]
  (throw (ex-info "reagent.core/render function was moved to reagent.dom namespace in Reagent v1.0"
                  (assoc (source-info &env) :tag :cljs/analysis-error)))
  nil)

dnolen15:11:37

I don't think so

dnolen15:11:00

I think analysis errors should be reserved for compiler problems

dnolen15:11:27

just write a regular function, and throw a reagent error

dnolen15:11:37

this is how core.async deals w/ <! etc. outside of go block