|
86 | 86 | _ (when (nil? ns) |
87 | 87 | (throw |
88 | 88 | (ex-info (str kw " symbol " sym " is not fully qualified") |
89 | | - (merge ex-data {kw sym})))) |
| 89 | + (merge ex-data {kw sym |
| 90 | + :clojure.error/phase :compilation})))) |
90 | 91 | var-ns (symbol ns)] |
91 | 92 | (when (not (find-ns var-ns)) |
92 | 93 | (try |
93 | 94 | (locking ana/load-mutex |
94 | 95 | (require var-ns)) |
95 | 96 | (catch Throwable t |
96 | 97 | (throw (ex-info (str "Cannot require namespace referred by " kw " value " sym) |
97 | | - (merge ex-data {kw sym}) |
| 98 | + (merge ex-data {kw sym |
| 99 | + :clojure.error/phase :compilation}) |
98 | 100 | t))))) |
99 | 101 |
|
100 | 102 | (find-var sym))) |
|
227 | 229 | (ex-info |
228 | 230 | (str "Invalid :closure-output-charset " charset " given, only " |
229 | 231 | (string/join ", " (keys string->charset)) " supported ") |
230 | | - {})))) |
| 232 | + {:clojure.error/phase :compilation})))) |
231 | 233 |
|
232 | 234 | (defn ^CompilerOptions$LanguageMode lang-key->lang-mode [key] |
233 | 235 | (case (keyword (string/replace (name key) #"^es" "ecmascript")) |
|
261 | 263 | :off AnonymousFunctionNamingPolicy/OFF |
262 | 264 | :unmapped AnonymousFunctionNamingPolicy/UNMAPPED |
263 | 265 | :mapped AnonymousFunctionNamingPolicy/MAPPED |
264 | | - (throw (IllegalArgumentException. (str "Invalid :anon-fn-naming-policy value " policy " - only :off, :unmapped, :mapped permitted"))))))) |
| 266 | + (throw (util/compilation-error (IllegalArgumentException. (str "Invalid :anon-fn-naming-policy value " policy " - only :off, :unmapped, :mapped permitted")))))))) |
265 | 267 |
|
266 | 268 | (when-let [lang-key (:language-in opts :ecmascript5)] |
267 | 269 | (.setLanguageIn compiler-options (lang-key->lang-mode lang-key))) |
|
369 | 371 | [{:keys [externs use-only-custom-externs target ups-externs infer-externs] :as opts}] |
370 | 372 | (let [validate (fn validate [p us] |
371 | 373 | (if (empty? us) |
372 | | - (throw (IllegalArgumentException. |
373 | | - (str "Extern " p " does not exist"))) |
| 374 | + (throw (util/compilation-error (IllegalArgumentException. |
| 375 | + (str "Extern " p " does not exist")))) |
374 | 376 | us)) |
375 | 377 | filter-cp-js (fn [paths] |
376 | 378 | (for [p paths |
|
413 | 415 | (doseq [next (seq warnings)] |
414 | 416 | (println "WARNING:" (.toString ^JSError next))) |
415 | 417 | (when (seq errors) |
416 | | - (throw (Exception. "Closure compilation failed")))))) |
| 418 | + (throw (util/compilation-error (Exception. "Closure compilation failed"))))))) |
417 | 419 |
|
418 | 420 | ;; Protocols for IJavaScript and Compilable |
419 | 421 | ;; ======================================== |
|
876 | 878 | (io/resource relpath)))] |
877 | 879 | {:relative-path relpath :uri js-res :ext :js} |
878 | 880 | (throw |
879 | | - (IllegalArgumentException. |
880 | | - (str "Namespace " ns " does not exist." |
881 | | - (when (string/includes? ns "-") |
882 | | - " Please check that namespaces with dashes use underscores in the ClojureScript file name."))))))))))))) |
| 881 | + (util/compilation-error |
| 882 | + (IllegalArgumentException. |
| 883 | + (str "Namespace " ns " does not exist." |
| 884 | + (when (string/includes? ns "-") |
| 885 | + " Please check that namespaces with dashes use underscores in the ClojureScript file name.")))))))))))))) |
883 | 886 |
|
884 | 887 | (defn cljs-dependencies |
885 | 888 | "Given a list of all required namespaces, return a list of |
|
1284 | 1287 | (swap! used into entries) |
1285 | 1288 | (into ret unused)) |
1286 | 1289 | (throw |
1287 | | - (IllegalArgumentException. |
1288 | | - (str "Could not find matching namespace for " entry-sym))))) |
| 1290 | + (util/compilation-error (IllegalArgumentException. |
| 1291 | + (str "Could not find matching namespace for " entry-sym)))))) |
1289 | 1292 | [] entries) |
1290 | 1293 | foreign-deps (atom [])] |
1291 | 1294 | ;; add inputs to module |
|
1304 | 1307 | (when (:verbose opts) |
1305 | 1308 | (util/debug-prn " module" name "depends on" dep)) |
1306 | 1309 | (.addDependency js-module ^JSModule parent-module)) |
1307 | | - (throw (IllegalArgumentException. |
1308 | | - (str "Parent module " dep " does not exist"))))) |
| 1310 | + (throw (util/compilation-error (IllegalArgumentException. |
| 1311 | + (str "Parent module " dep " does not exist")))))) |
1309 | 1312 | (conj ret |
1310 | 1313 | [name (assoc module-desc |
1311 | 1314 | :closure-module js-module |
|
2052 | 2055 | (deps/-closure-lib? js) |
2053 | 2056 | (deps/-foreign? js))) |
2054 | 2057 | (catch Throwable t |
2055 | | - (throw (Exception. (str "Could not write JavaScript " (pr-str js))))))) |
| 2058 | + (throw (util/compilation-error (Exception. (str "Could not write JavaScript " (pr-str js)))))))) |
2056 | 2059 |
|
2057 | 2060 | (defn source-on-disk |
2058 | 2061 | "Ensure that the given IJavaScript exists on disk in the output directory. |
|
2160 | 2163 | (:url-min ijs)) |
2161 | 2164 | (:url ijs))] |
2162 | 2165 | (slurp url) |
2163 | | - (throw (IllegalArgumentException. |
2164 | | - (str "Foreign lib " ijs " does not exist")))))] |
| 2166 | + (throw (util/compilation-error (IllegalArgumentException. |
| 2167 | + (str "Foreign lib " ijs " does not exist"))))))] |
2165 | 2168 | (str (string/join "\n" (map to-js-str sources)) "\n"))) |
2166 | 2169 |
|
2167 | 2170 | (defn add-wrapper [{:keys [output-wrapper] :as opts} js] |
|
2689 | 2692 | (catch Throwable t |
2690 | 2693 | (throw (ex-info (str "Error running preprocessing function " preprocess) |
2691 | 2694 | {:file (:file js-module) |
2692 | | - :preprocess preprocess} |
| 2695 | + :preprocess preprocess |
| 2696 | + :clojure.error/phase :compilation} |
2693 | 2697 | t))))) |
2694 | 2698 |
|
2695 | 2699 | :else |
|
2772 | 2776 | (let [new-mappings (reader/read {:eof nil :read-cond :allow} rdr)] |
2773 | 2777 | (when (not (map? new-mappings)) |
2774 | 2778 | (throw (ex-info (str "Not a valid data-reader map") |
2775 | | - {:url url}))) |
| 2779 | + {:url url |
| 2780 | + :clojure.error/phase :compilation}))) |
2776 | 2781 | (reduce |
2777 | 2782 | (fn [m [k v]] |
2778 | 2783 | (when (not (symbol? k)) |
2779 | 2784 | (throw (ex-info (str "Invalid form in data-reader file") |
2780 | 2785 | {:url url |
2781 | | - :form k}))) |
| 2786 | + :form k |
| 2787 | + :clojure.error/phase :compilation}))) |
2782 | 2788 | (when (and (contains? mappings k) |
2783 | 2789 | (not= (mappings k) v)) |
2784 | 2790 | (throw (ex-info "Conflicting data-reader mapping" |
2785 | 2791 | {:url url |
2786 | 2792 | :conflict k |
2787 | | - :mappings m}))) |
| 2793 | + :mappings m |
| 2794 | + :clojure.error/phase :compilation}))) |
2788 | 2795 | (assoc m k v)) |
2789 | 2796 | mappings |
2790 | 2797 | new-mappings))))) |
|
3241 | 3248 | "js" (cond-> (:provides (parse-js-ns src)) |
3242 | 3249 | (not all-provides) first) |
3243 | 3250 | (throw |
3244 | | - (IllegalArgumentException. |
3245 | | - (str "Can't create goog.require expression for " src))))] |
| 3251 | + (util/compilation-error (IllegalArgumentException. |
| 3252 | + (str "Can't create goog.require expression for " src)))))] |
3246 | 3253 | (if (and (not all-provides) wrap) |
3247 | 3254 | (if (:reload options) |
3248 | 3255 | (str "goog.require(\"" goog-ns "\", true);") |
|
0 commit comments