AvisoNovate / rook

Smart namespace-driven routing for Pedestal
http://rook.readthedocs.io/en/latest/index.html
Apache License 2.0
75 stars 11 forks source link

Better error message for invalid :path-spec #17

Closed hlship closed 10 years ago

hlship commented 10 years ago
    data: {:operation-trace
           ("Identifying resource handler functions in `fan.resources.invoices'.")}
           java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.CharSequence
                                                      clojure.string/split                        string.clj:  224
                            io.aviso.rook.dispatcher/path-spec->route-spec                    dispatcher.clj:  105
            io.aviso.rook.dispatcher/simple-namespace-dispatch-table/fn/fn                    dispatcher.clj:  658
                                                      clojure.core/keep/fn                          core.clj: 6713
                                                 clojure.lang.LazySeq.sval                      LazySeq.java:   40
                                                  clojure.lang.LazySeq.seq                      LazySeq.java:   49
                                                    clojure.lang.Cons.next                         Cons.java:   39
                                      clojure.lang.PersistentVector.create             PersistentVector.java:   51
                                clojure.lang.LazilyPersistentVector.create       LazilyPersistentVector.java:   31
                                                          clojure.core/vec                          core.clj:  354
               io.aviso.rook.dispatcher/simple-namespace-dispatch-table/fn                    dispatcher.clj:  654
                                                   io.aviso.tracker/track*                       tracker.clj:   41
                  io.aviso.rook.dispatcher/simple-namespace-dispatch-table                    dispatcher.clj:  641
                      io.aviso.rook.dispatcher/namespace-dispatch-table/fn                    dispatcher.clj:  727
                                                       clojure.core/map/fn                          core.clj: 2557
                                                 clojure.lang.LazySeq.sval                      LazySeq.java:   40
                                                  clojure.lang.LazySeq.seq                      LazySeq.java:   49
                                      clojure.lang.ChunkedCons.chunkedNext                  ChunkedCons.java:   59
                                                   clojure.core/chunk-next                          core.clj:  667
                                                 clojure.core.protocols/fn                     protocols.clj:  101
                                               clojure.core.protocols/fn/G                     protocols.clj:   19
                                         clojure.core.protocols/seq-reduce                     protocols.clj:   31
                                                 clojure.core.protocols/fn                     protocols.clj:   54
                                               clojure.core.protocols/fn/G                     protocols.clj:   13
                                                       clojure.core/reduce                          core.clj: 6289
                         io.aviso.rook.dispatcher/namespace-dispatch-table                    dispatcher.clj:  723
                                               clojure.lang.RestFn.applyTo                       RestFn.java:  139
                                                        clojure.core/apply                          core.clj:  626
                                           io.aviso.rook/namespace-handler                          rook.clj:  105

This took some time to analyze, it was caused by:

(defn join-issuer
  "Allows an issuer to join an invoice. The issuer is identified by the entity associated with the API key used for authorization."
  {:path-spec [:put ["/:payment-code/join"]]
   :schema    join-issuer-schema
   :responses join-issuer-responses}

A better failure would check that the second value in :path-spec is a string.