Anybody have some for-dummies tutorial on creating custom Exception types in Clojure? Pedestal seems to rely on custom exceptions in io.pedestal.interceptor.error/error-dispatch
, but Clojure favours throwing ex-info
everywhere which doesn’t really mesh well with Pedestal.
Or maybe I’ll just throw ex-info everywhere and not dispatch on exception type…
Guess I can just check the content of every clojure.lang.ExceptionInfo
Not a direct answer. I’ve been leaning hard on https://github.com/cognitect-labs/anomalies - and it is also what Datomic generates, so that meshes well with my life
I’ve seen those before, but I was unsure if the idea is to use this as ex-data keys.
Wherever is sensible, I try/catch and return a map with an anomaly. Then somewhere else, I pull out of that map what I want, or deal with that anomaly. I don’t let exceptions bubble up. I let data flow through.
@simongray I also recommend using anomalies or some other form of "classification" beyond java types. Catch ExceptionInfo and match on whatever content in ex-data to determine what to do with it. And then there is https://github.com/scgilardi/slingshot