Fork me on GitHub
#pedestal
<
2020-11-27
>
simongray11:11:10

I don’t think I quite understand error handling. According to http://Pedestal.io: > As long as there is an error attached to that key, Pedestal will not invoke the usual `:enter` and `:leave` functions. Instead, it looks for the next interceptor in the chain that has a `:error` function attached to it. So I would expect that throwing an exception in the :enter function would look for the exception handling Interceptor next in the queue. However, the behaviour actually seems to be the opposite: only Interceptors that come before the throwing Interceptor are considered.

simongray11:11:05

I guess “the chain” really means “Interceptors that have been visited at least once”.

simongray11:11:25

and then anything that comes after the throwing Interceptor is thrown out.

simongray11:11:11

So should error handlers always be put at the very beginning of the Interceptors vector?

orestis11:11:50

yes, a thrown exception AFAIK will terminate the queue and start unwinding

👍 3
souenzzo11:11:45

I found some tests with routing with :app-name // :host But I can't make it work. There is any sample app using this? (i prefer tabular routes once all my routes are tabular at this moment) https://github.com/pedestal/pedestal/blob/aa71a3a630dd21861c0682eeeebec762cbf3f85c/service/test/io/pedestal/http/route_test.clj#L285

souenzzo11:11:58

I'm trying with

::http/routes (vec (concat
                     (route/expand-routes red-green)
                     (route/expand-routes todo-list)))
It throws
Execution error (AssertionError) at io.pedestal.http.route.definition.terse/eval12443$fn (terse.clj:52).
Assert failed: Cannot expand '[:path "/red"]' as a route. Expected a verb map or path string, but found a class clojure.lang.MapEntry instead
false

souenzzo11:11:52

OK, i should just concat, not vec concat

souenzzo11:11:26

Pedestal is awesome. If there is docs for it, it would be a good clojure selling point

ddeaguiar15:11:44

@U2J4FRT2T by using vec you inadvertently switched routing syntax. FWIW, the docs do http://pedestal.io/reference/routing-quick-reference#_routes the relation between routing syntax and data structure type.