middleware.clj

website.git ยท Tickets

website.git > main > 105221d > files / src / dev / grahp / website / middleware.clj

(ns dev.grahp.website.middleware
  (:require
   [clojure.tools.logging :as log]))

(defn wrap-errors
  "Returns an Internal Server Error when the app throws an Exception."
  [app]
  (fn [request]
    (try (app request)
         (catch Exception e
           (log/error e)
           (flush)
           {:status 500
            :headers {"Content-Type" "text/html"}
            :body "Internal server error! D:\n\nPlease tell Grahp!"}))))