pedestal

simongray 2021-05-21T08:19:25.017200Z

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.

simongray 2021-05-21T08:21:50.017800Z

Or maybe I’ll just throw ex-info everywhere and not dispatch on exception type…

simongray 2021-05-21T08:23:02.018600Z

Guess I can just check the content of every clojure.lang.ExceptionInfo

danieroux 2021-05-21T08:27:32.018700Z

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

simongray 2021-05-21T08:34:19.019Z

I’ve seen those before, but I was unsure if the idea is to use this as ex-data keys.

danieroux 2021-05-21T08:42:48.019200Z

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.

ordnungswidrig 2021-05-21T14:19:20.020700Z

@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