Liking cljdoc? Tell your friends :D

reitit.http.interceptors.exception


create-coercion-handlerclj

(create-coercion-handler status)

Creates a coercion exception handler.

Creates a coercion exception handler.
sourceraw docstring

default-handlerclj

(default-handler e _)

Default safe handler for any exception.

Default safe handler for any exception.
sourceraw docstring

default-handlersclj

source

exception-interceptorclj

(exception-interceptor)
(exception-interceptor handlers)

Creates an Interceptor that catches all exceptions. Takes a map of identifier => exception request => response that is used to select the exception handler for the thrown/raised exception identifier. Exception identifier is either a Keyword or a Exception Class.

The following handlers special handlers are available:

keydescription
::exception/defaulta default exception handler if nothing else matched (default default-handler).
::exception/wrapa 3-arity handler to wrap the actual handler handler exception request => response

The handler is selected from the options map by exception identifier in the following lookup order:

  1. :type of exception ex-data
  2. Class of exception
  3. :type ancestors of exception ex-data
  4. Super Classes of exception
  5. The ::default handler

Example:

(require '[reitit.ring.interceptors.exception :as exception])

;; type hierarchy
(derive ::error ::exception)
(derive ::failure ::exception)
(derive ::horror ::exception)

(defn handler [message exception request]
  {:status 500
   :body {:message message
          :exception (str exception)
          :uri (:uri request)}})

(exception/exception-interceptor
  (merge
    exception/default-handlers
    {;; ex-data with :type ::error
     ::error (partial handler "error")

     ;; ex-data with ::exception or ::failure
     ::exception (partial handler "exception")

     ;; SQLException and all it's child classes
     java.sql.SQLException (partial handler "sql-exception")

     ;; override the default handler
     ::exception/default (partial handler "default")

     ;; print stack-traces for all exceptions
     ::exception/wrap (fn [handler e request]
                        (.printStackTrace e)
                        (handler e request))}))
Creates an Interceptor that catches all exceptions. Takes a map
of `identifier => exception request => response` that is used to select
the exception handler for the thrown/raised exception identifier. Exception
identifier is either a `Keyword` or a Exception Class.

The following handlers special handlers are available:

| key                    | description
|------------------------|-------------
| `::exception/default`  | a default exception handler if nothing else matched (default [[default-handler]]).
| `::exception/wrap`     | a 3-arity handler to wrap the actual handler `handler exception request => response`

The handler is selected from the options map by exception identifier
in the following lookup order:

1) `:type` of exception ex-data
2) Class of exception
3) `:type` ancestors of exception ex-data
4) Super Classes of exception
5) The ::default handler

Example:

    (require '[reitit.ring.interceptors.exception :as exception])

    ;; type hierarchy
    (derive ::error ::exception)
    (derive ::failure ::exception)
    (derive ::horror ::exception)

    (defn handler [message exception request]
      {:status 500
       :body {:message message
              :exception (str exception)
              :uri (:uri request)}})

    (exception/exception-interceptor
      (merge
        exception/default-handlers
        {;; ex-data with :type ::error
         ::error (partial handler "error")

         ;; ex-data with ::exception or ::failure
         ::exception (partial handler "exception")

         ;; SQLException and all it's child classes
         java.sql.SQLException (partial handler "sql-exception")

         ;; override the default handler
         ::exception/default (partial handler "default")

         ;; print stack-traces for all exceptions
         ::exception/wrap (fn [handler e request]
                            (.printStackTrace e)
                            (handler e request))}))
sourceraw docstring

http-response-handlerclj

(http-response-handler e _)

Reads response from Exception ex-data :response

Reads response from Exception ex-data :response
sourceraw docstring

print!clj

(print! writer & more)
source

request-parsing-handlerclj

(request-parsing-handler e _)
source

wrap-log-to-consoleclj

(wrap-log-to-console handler e {:keys [uri request-method] :as req})
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close