https://kotlinlang.org logo
Title
o

obobo

03/19/2019, 4:43 PM
Also, I'm using
ContentNegotiation
, and trying to use
receiveOrNull
to 'safely' get a POST body, and it feels much less useful/safe than I'd expect it to be. If I send an empty body or try to instance a data object with non-nullable fields
receiveOrNull
will throw an exception. Is this by design?
b

bdawg.io

03/19/2019, 11:03 PM
IIRC, that only returns null if 1) content transformation was successful and 2) the type you expected
receiveOrNull<MyType>()
was not returned by transformation
o

obobo

03/20/2019, 4:55 PM
Right, I'm wondering if that's by design, because I have to then be aware of the exceptions thrown by the implementation, or catch something generic like
IOException
if I want
receiveOrNull
to be safe. I always felt that the
OrNull
functions were for situations where you don't particularly care why something failed.