(ns lens.middleware.wan-exception
  (:require [clj-stacktrace.repl :refer [pst-on]]))

(defn wrap-exception
  "Calls the handler in a try catch block returning a WAN error response."
  [handler]
  (fn [request]
    (try
      (handler request)
      (catch Throwable e
        (pst-on *err* false e)
        {:status 500
         :body {:error (.getMessage e)}}))))

(ns lens.middleware.wan-exception
  (:require [clj-stacktrace.repl :refer [pst-on]]))

(defn wrap-exception
  "Calls the handler in a try catch block returning a WAN error response."
  [handler]
  (fn [request]
    (try
      (handler request)
      (catch Throwable e
        (pst-on *err* false e)
        {:status 500
         :body
         {:links {:up {:href "/"}}
          :error (.getMessage e)}}))))

Add Up Link to Error Representation
Add Up Link to Error Representation

alexanderkiel/lens-warehouse