Fork me on GitHub
#reitit
<
2020-02-26
>
oly10:02:44

hi, hoping someone might be able give me some pointers I am having issues with an exception but I have no traceback

"class": "java.lang.Exception"
only the above message, I know it related to the body, if i run my function it returns a hash map successfully but when passed into body it returns the above message replacing the function call with a hash map works so it seems its related to converting to json or edn anyway i can get a full stack trace ?

oly10:02:56

I have these middlewares enabled swagger/swagger-feature parameters/parameters-middleware muuntaja/format-negotiate-middleware muuntaja/format-response-middleware exception/exception-middleware muuntaja/format-request-middleware coercion/coerce-response-middleware coercion/coerce-request-middleware

mgrbyte11:02:10

iirc, I think you can get the full stack trace if you disable (un-comment) exception/exception-middleware

oly11:02:00

I do have that middleware enabled above

oly11:02:32

but it fails to give a full stack trace, I have figured out the issue now, basically database was not setup when run through the api

oly11:02:03

but I would love a way to get a full trace, seems this sort of error would have been easy to spot if it had not been hidden

mgrbyte11:02:05

"disable" ☝️ 🙂

oly11:02:26

oh so comment out the exception middleware

mgrbyte11:02:37

I think I overrode the exception middleware (wrote my own) that wraps the original and logs the exception (available stacktrace). could also just print it, depends what you want.

oly11:02:47

oh yeah that works, seems counter intuitive would expect it to catch the full exception and return

oly11:02:16

that's helpful anyway thanks for that spent so much time trying to diagnose that

oly14:02:57

Another question 🙂 any way to convert this format from honeysql to a json string :release_date #clj-time/date-time "2019-04-30T23:00:00.000Z" currently muuntaja is coercing it into its parts like below. "release_date": { "year": 2019, "dayOfMonth": 30, "dayOfYear": 120, "dayOfWeek": 2, "era": 1,

oly14:02:39

I have been looking into coercision via spec tools but finding it difficult to work with, figure this is a common requirement so likely an easier way ?

juhoteperi14:02:09

@oliver.marks check the last example here, about adding JodaTime support to Jsonista: https://github.com/metosin/jsonista#examples (and check Muuntaja/Reitit docs about adding those Jsonista options)

oly15:02:53

okay thanks will see if i can figure out how to add that 🙂

oly16:02:14

not having much luck with jsonista, perhaps i am confused. I have created a new muuntaja instance with (assoc-in [:formats "application/json" :encoder-opts :date-format] "yyyy-MM-dd")))) but it does not change the format

oly16:02:43

the link has you creating a mapper do you need to inject that mapper into the encoder-opts in some way

oly16:02:21

dont suppose there is a working example around some where ?

oly16:02:17

taking it to a much simpler example this is what I am testing with. (def new-muuntaja-instance (m/create (-> m/default-options (assoc-in [:formats "application/json" :encoder-opts :date-format] "yyyy-MM-dd")))) (->> {:test (LocalDate. 0)} (m/encode new-muuntaja-instance "application/json" ) (m/decode new-muuntaja-instance "application/json" ))

rickmoynihan16:02:51

Is it possible with client side reitit to use both fragment routes and non-fragment routes simultaneously?

oly16:02:23

got a step further seems its because the database is returning dates in joda time and the example uses (java.util.Date.)

oly16:02:37

so the date formatting is not applied not sure how to correct that

oly16:02:50

finally figured it out, needed to pass :module to the encoder-opts :)