Ray Eldath
01/27/2020, 5:25 AMjacksonObjectMapper().writeValueAsString(e)
to manually convert the object, and it works fine now.
i feel somewhat strange about the origin behavior. use writeValueAsString
will format the stacktrace into a well-organized json but .with(error of e)
will output the stacktrace solely which will crash the json parser. why with
is designed to work in this way...? 😕dave
01/27/2020, 6:33 AMRay Eldath
01/27/2020, 6:48 AMJackson.asjsonString
or ... of object
will leads to the solely string reply, constituted of the stacktrace string containing lots of \r\n
with Content-Type application-json
, but it's not a json object.
Use jacksonObjectMapper().writeValueAsString(object)
from package com.fasterxml.jackson.module.kotlin
to convert manually will works fine, output the well-organized data.dave
01/27/2020, 6:51 AMRay Eldath
01/27/2020, 7:08 AMAutoMappingConfiguration
... it's specify text(throwable())
explicitly, remove this line will make Exception
serialized normally.
should this be proposed as a pr...? i think we should provide some options for user to easily turn on/off the normal serialization of Throwable.
this may derived from the assumption that all exception is child-field, so encoded them as text will produce more concise json string. but when they're not, it will cause problem. as described in #361. 🐱dave
01/28/2020, 11:45 AMRay Eldath
01/28/2020, 11:57 AMException
to indicate my custom diagnose message is technically absolutely no problem. but the code is kinda crazy - you have to write something like req -> run { return@run Response(...) }
to throw the simple exception wrapper to the client. so i build a exception-based solution, enable me to use throw
directly.
well, after all, i think there should have - if not have currently - some guidelines about these exception behavior.