Fork me on GitHub
#yada
<
2022-12-01
>
danielneal13:12:45

heya, does anyone know if it’s possible to get the original ctx in a yada error-handler. I’m trying to log the body of a POST request when there’s an error, but the processed request body is not present

mccraigmccraig21:02:49

iirc the body is (sometimes, perhaps not always) in a stateful InputStream, and once that is consumed it's gone - unless you keep a reference to whatever you parsed out of the InputStream so you could add an interceptor to read the InputStream, add the parsed value to the ctx and put a ByteArrayInputStream back in to the ctx to replace the original InputStream

danielneal12:02:57

thanks so much!

pppaul01:02:20

there should be a PR by me on the yada repo that does just this

pppaul01:02:06

my PR gives the CTX up to the error, and then starts the error interceptors with that ctx. if that is what you need then look at that PR