From e0d36761969a96c8fd1a7a64a9795c0c8b6972be Mon Sep 17 00:00:00 2001 From: Yogthos Date: Thu, 2 Apr 2015 22:22:17 -0400 Subject: [PATCH] added an error check for parsing the config.edn --- project.clj | 2 +- src/cryogen_core/compiler.clj | 37 +++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/project.clj b/project.clj index 7e40f3c..adf7b6e 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject cryogen-core "0.1.20" +(defproject cryogen-core "0.1.21" :description "Cryogen's compiler" :url "https://github.com/lacarmen/cryogen-core" :license {:name "Eclipse Public License" diff --git a/src/cryogen_core/compiler.clj b/src/cryogen_core/compiler.clj index b07afa7..155e774 100644 --- a/src/cryogen_core/compiler.clj +++ b/src/cryogen_core/compiler.clj @@ -266,23 +266,26 @@ (defn read-config "Reads the config file" [] - (let [config (-> "templates/config.edn" - get-resource - slurp - read-string - (update-in [:blog-prefix] (fnil str "")) - (update-in [:rss-name] (fnil str "rss.xml")) - (update-in [:rss-filters] (fnil seq [])) - (update-in [:sass-src] (fnil str "css")) - (update-in [:sass-dest] (fnil str "css")) - (update-in [:post-date-format] (fnil str "yyyy-MM-dd")) - (update-in [:keep-files] (fnil seq [])) - (update-in [:ignored-files] (fnil seq [#"^\.#.*" #".*\.swp$"])))] - (merge - config - {:page-root (root-path :page-root config) - :post-root (root-path :post-root config) - :tag-root (root-path :tag-root config)}))) + (try + (let [config (-> "templates/config.edn" + get-resource + slurp + read-string + (update-in [:blog-prefix] (fnil str "")) + (update-in [:rss-name] (fnil str "rss.xml")) + (update-in [:rss-filters] (fnil seq [])) + (update-in [:sass-src] (fnil str "css")) + (update-in [:sass-dest] (fnil str "css")) + (update-in [:post-date-format] (fnil str "yyyy-MM-dd")) + (update-in [:keep-files] (fnil seq [])) + (update-in [:ignored-files] (fnil seq [#"^\.#.*" #".*\.swp$"])))] + (merge + config + {:page-root (root-path :page-root config) + :post-root (root-path :post-root config) + :tag-root (root-path :tag-root config)})) + (catch Exception _ + (throw (IllegalArgumentException. "Failed to parse config.edn"))))) (defn compile-assets "Generates all the html and copies over resources specified in the config"