adl-support.core

Application Description Language support - utility functions likely to be useful in user-written code.

*warn*

dynamic

The idea here is to have a function with which to show warnings to the user, which can be dynamically bound. Any binding should be a function of one argument, which it should print, log, or otherwise display.

compose-exception-reason

macro

(compose-exception-reason exception intro)(compose-exception-reason exception)

Compose and return a sensible reason message for this exception.

compose-reason-and-log

macro

(compose-reason-and-log exception intro)(compose-reason-and-log exception)

Compose a reason message for this exception, log it (with its stacktrace), and return the reason message.

do-or-log-and-return-reason

macro

(do-or-log-and-return-reason form)

Clojure stacktraces are unreadable. We have to do better; evaluate this form in a try-catch block; return a map. If the evaluation succeeds, the map will have a key :result whose value is the result; otherwise it will have a key :error which will be bound to the most sensible error message we can construct. Additionally, log the exception

do-or-log-error

macro

(do-or-log-error form & {:keys [message error-return], :or {message (clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/str)) (clojure.core/list "A failure occurred in ") (clojure.core/list (list (quote quote) form))))}})

Evaluate the supplied form in a try/catch block. If the keyword param :message is supplied, the value will be used as the log message; if the keyword param :error-return is supplied, the value will be returned if an exception is caught.

do-or-return-reason

macro

(do-or-return-reason form intro)(do-or-return-reason form)

Clojure stacktraces are unreadable. We have to do better; evaluate this form in a try-catch block; return a map. If the evaluation succeeds, the map will have a key :result whose value is the result; otherwise it will have a key :error which will be bound to the most sensible error message we can construct.

do-or-warn

macro

(do-or-warn form)(do-or-warn form intro)

Evaluate this form; if any exception is thrown, show it to the user via the *warn* mechanism.

do-or-warn-and-log

macro

(do-or-warn-and-log form)(do-or-warn-and-log form intro)

Evaluate this form; if any exception is thrown, log the reason and show it to the user via the *warn* mechanism.

massage-params

Sending empty strings, or numbers as strings, to the database often isn’t helpful. Massage these params and form-params to eliminate these problems. We must take key field values out of just params, but we should take all other values out of form-params - because we need the key to load the form in the first place, but just accepting values of other params would allow spoofing.

massage-value

(massage-value k m)

Return a map with one key, this k as a keyword, whose value is the binding of k in map m, as read by read.

raw-massage-params

(raw-massage-params request entity)(raw-massage-params request)

Sending empty strings, or numbers as strings, to the database often isn’t helpful. Massage these params and form-params to eliminate these problems. Date and time fields also need massaging.

raw-resolve-template

(raw-resolve-template n)

FIXME: write docs

resolve-template

FIXME: write docs