Ktorfit icon indicating copy to clipboard operation
Ktorfit copied to clipboard

Nullable return type causes hides network errors

Open OSemenovBoyarka opened this issue 7 months ago • 1 comments

Ktorfit version

2.0.0

What happened and how can we reproduce this issue?

I had some Ktofit service interfaces with nullable return types, e.g.:

@GET("some/path")
suspend fun getSomeData(): SomeDataType?

In case I have network error for such requests - function just returns null and not throw any errors.

What did you expect to happen?

If a request encountered network error - I expect exception to be thrown. And I expect function to return null in case backend returned empty response body.

In case this is an intended behavior - I think it should be documented.

Is there anything else we need to know about?

https://github.com/Foso/Ktorfit/pull/63/files#diff-abbd410f22e11a5dce5bd808ce8218aab2dfb8653b00ecc8d43f55cbe93b066aR66

OSemenovBoyarka avatar Jul 24 '24 14:07 OSemenovBoyarka