Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

resilience in exception page and cookies fix

Signed-off-by: Chris Granger <chris@readyforzero.com>
  • Loading branch information...
commit 3364cb5d712f3652213721603b660b2407801029 1 parent 8257dc7
Chris Granger authored
View
2  project.clj
@@ -7,7 +7,7 @@
[ring "0.3.11"]
[cssgen "0.2.4"]
[hiccup "0.3.6"]
- [clj-stacktrace "0.2.2"]
+ [clj-stacktrace "0.2.3"]
[ring-reload-modified "0.1.0"]
[net.java.dev.jets3t/jets3t "0.8.0"]
[org.mindrot/jbcrypt "0.3m"]]
View
6 src/noir/content/defaults.clj
@@ -45,8 +45,10 @@
[:table [:tbody (map exception-item (:trace-elems exception))]]
(for [cause causes :while cause]
[:div.cause
- [:h3 "Caused by: " (:class cause) " - " (:message cause)]
- [:table (map exception-item (:trimmed-elems cause))]])]
+ (try
+ [:h3 "Caused by: " (:class cause) " - " (:message cause)]
+ [:table (map exception-item (:trimmed-elems cause))]
+ (catch Throwable e))])]
))
(defpartial internal-error []
View
2  src/noir/cookies.clj
@@ -24,7 +24,7 @@
([k] (get k nil))
([k default]
(let [str-k (name k)]
- (if-let [v (or (get-in *new-cookies* [str-k :value])
+ (if-let [v (or (get-in @*new-cookies* [str-k :value])
(get-in *cur-cookies* [str-k :value]))]
v
default))))
View
5 src/noir/exception.clj
@@ -60,7 +60,10 @@
(catch Exception e
(.printStackTrace e)
(let [content (if (options/dev-mode?)
- (defaults/stack-trace (parse-ex e))
+ (try
+ (defaults/stack-trace (parse-ex e))
+ (catch Throwable e
+ (statuses/get-page 500)))
(statuses/get-page 500))]
{:status 500
:headers {"Content-Type" "text/html"}
View
25 test/noir/test/core.clj
@@ -19,26 +19,25 @@
(is (nil? (session/get :noir)))
(is (= "noir" (session/get :noir "noir")))))
-(deftest cookies-get-default
+(deftest cookies
(with-noir
+ (cookies/put! :noir2 "woo")
+ (is (= "woo" (cookies/get :noir2)))
(is (nil? (cookies/get :noir)))
(is (= "noir" (cookies/get :noir "noir")))))
(deftest cookies-get-signed
(with-noir
- (is (nil? (cookies/get :noir)))
- (cookies/put-signed! "s3cr3t-k3y" :noir "stored-value")
- ;; Use new cookies as cur.
- (binding [cookies/*cur-cookies* @cookies/*new-cookies*]
- ;; Check default behavior for bad keys.
- (is (nil? (cookies/get-signed "b4d-k3y" :noir)))
- (is (= "noir" (cookies/get-signed "b4d-k3y" :noir "noir")))
- ;; Check retrieval of good value.
- (is (= "stored-value" (cookies/get-signed "s3cr3t-k3y" :noir))))
+ (is (nil? (cookies/get :noir3)))
+ (cookies/put-signed! "s3cr3t-k3y" :noir3 "stored-value")
+ ;; Check default behavior for bad keys.
+ (is (nil? (cookies/get-signed "b4d-k3y" :noir3)))
+ (is (= "noir" (cookies/get-signed "b4d-k3y" :noir3 "noir")))
+ ;; Check retrieval of good value.
+ (is (= "stored-value" (cookies/get-signed "s3cr3t-k3y" :noir3)))
;; Modify value,
- (binding [cookies/*cur-cookies* (assoc @cookies/*new-cookies* "noir" "changed-value")]
- ;; Check that it's not returned.
- (is (nil? (cookies/get-signed "s3cr3t-k3y" :noir))))))
+ (cookies/put! :noir3 "changed-value")
+ (is (nil? (cookies/get-signed "s3cr3t-k3y" :noir3)))))
(deftest options-get-default
(with-noir
Please sign in to comment.
Something went wrong with that request. Please try again.