Classify exceptions into BND-xxx error codes. Pure functions — catalog data loaded once at namespace init via wagoe.devtools.error-codes.
Classification strategy (ordered, first match wins):
Classify exceptions into BND-xxx error codes. Pure functions — catalog data loaded once at namespace init via wagoe.devtools.error-codes. Classification strategy (ordered, first match wins): 1. ex-data with :wagoe/error-code — direct BND code 2. ex-data pattern matching — infer from :type, :schema, :malli/error 3. Message pattern — regex on .getMessage() 4. Exception type — SQLException, ConnectException, etc. 5. Unclassified — nil code
(classify exception)Classify an exception into a BND-xxx error code.
Order, and why. An explicit :wagoe/error-code wins. Then the outermost
exception's own ex-data: the code that threw chose a :type, and that
choice is better information than the class of whatever it wrapped. Only
then the root cause — its ex-data, its message, its class.
Reading the root cause first is what this used to do, and it produced the
wrong answer for every wrapped database failure: an INSERT violating a
unique constraint is thrown as {:type :database-error} around a
SQLException, and instance? SQLException reported BND-303 "Database
Connection Failed — verify the database is running" (BOU-323).
Returns a map with :code, :category, :exception, :data, :source or a map with :code nil for unclassified errors.
Classify an exception into a BND-xxx error code.
Order, and why. An explicit `:wagoe/error-code` wins. Then the *outermost*
exception's own ex-data: the code that threw chose a `:type`, and that
choice is better information than the class of whatever it wrapped. Only
then the root cause — its ex-data, its message, its class.
Reading the root cause first is what this used to do, and it produced the
wrong answer for every wrapped database failure: an INSERT violating a
unique constraint is thrown as `{:type :database-error}` around a
`SQLException`, and `instance? SQLException` reported BND-303 "Database
Connection Failed — verify the database is running" (BOU-323).
Returns a map with :code, :category, :exception, :data, :source
or a map with :code nil for unclassified errors.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |