From f53fcdb451f609466e20a390facdbc13b9f2ea17 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 11 Sep 2017 11:40:04 +0100 Subject: [PATCH] Improved error handling when totally invalid header is provided. --- src/scot/weft/i18n/core.clj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scot/weft/i18n/core.clj b/src/scot/weft/i18n/core.clj index 0a0e4ce..a7cbec7 100644 --- a/src/scot/weft/i18n/core.clj +++ b/src/scot/weft/i18n/core.clj @@ -2,6 +2,7 @@ :author "Simon Brooke"} scot.weft.i18n.core (:require [clojure.java.io :as io] + [clojure.pprint :refer [pprint]] [clojure.string :refer [join]] [instaparse.core :as insta] [taoensso.timbre :as timbre])) @@ -78,7 +79,10 @@ (generate-accept-languages (second parse-tree))) :SUB-TAG (second parse-tree) :Q-SEP nil - :Q-VALUE (read-string (second parse-tree))))) + :Q-VALUE (read-string (second parse-tree)) + ;; default + (let [formatted-tree (with-out-str (pprint parse-tree))] + (throw (Exception. (str "Unexpected parse tree: " formatted-tree))))))) (defn acceptable-languages