           (ex-info (str "Couldn't read the file:" f)
                    {::error true} t)))))
 
+(defn read-edn-string [s & [fail-msg]]
+  (try
+    (edn/read-string s)
+    (catch Throwable e
+      (throw (ex-info (str
+                       (.getMessage e) "\n"
+                       (or fail-msg "Failed to read EDN string: ")
+                       (pr-str s))
+                      {::error true}
+                      e)))))
+
 (defn read-edn-opts [str]
   (letfn [(read-rsrc [rsrc-str orig-str]
             (if-let [rsrc (io/resource rsrc-str)]
-              (edn/read-string (slurp rsrc))
+              (read-edn-string (slurp rsrc))
               (cljs.cli/missing-resource orig-str)))]
     (cond
      (string/starts-with? str "@/") (read-rsrc (subs str 2) str)

         (read-edn-file f)
         (cljs.cli/missing-file str))))))

(defn load-edn-opts [str]
  (reduce merge {} (map read-edn-opts (cljs.util/split-paths str))))

(defn figwheel-opts-opt
  [cfg ropts]
  (let [ropts (string/trim ropts)
        edn   (if (string/starts-with? ropts "{")
                (try
                  (edn/read-string ropts)
                  (catch Throwable e
                    (throw (ex-info (str
                                     (.getMessage e) "\n"
                                     "Error reading EDN from command line: -fwo " (pr-str ropts))
                                    {::error true}
                                    e))))
                (load-edn-opts ropts))]
    (validate-config! edn "Error validating figwheel options EDN provided to -fwo CLI flag")
    (update cfg ::config merge edn)))

          {:group :cljs.cli/compile :fn figwheel-opts-opt
           :arg "edn"
           :doc (str "Options to configure figwheel.main, can be an EDN string or "
                     "system-dependent path-separated list of EDN files / classpath resources. Options "
                     "will be merged left to right.")}
          ["-co" "--compile-opts"]
          {:group :cljs.cli/main&compile :fn compile-opts-opt
           :arg "edn"
           :doc (str "Options to configure the build, can be an EDN string or "
                     "system-dependent path-separated list of EDN files / classpath resources. Options "
                     "will be merged left to right.")}
          ;; TODO uncertain about this
