C
C#ā€¢2y ago
growlingOwl

āœ… BaseApiClient - help on handling null returns / exceptions, logging

Hello! I am pretty new here. I've been following some real world examples I have in my life and been trying to just wrap my mind about everything and make a solid BaseApiClient class. What I currently have is seen in the pictures. What I currently don't like is how I get a warning message of possible null return on all DeserializeAsync. How would you guys handle these calls? And I am also quite new to logging. Should I log something in this class as well? (for example the response content in EnsureSuccess method) šŸ™šŸ¾ šŸ»
4 Replies
Anton
Antonā€¢2y ago
Stack Overflow
Is null valid JSON (4 bytes, nothing else)
Hot debate today: Is the text stream null valid JSON? According to http://www.ietf.org/rfc/rfc4627.txt?number=4627: ... 2. JSON Grammar
A JSON text is a sequence of tokens. The set of
Anton
Antonā€¢2y ago
null is a valid response return Task<Response?> or enforce that it's not null with an exception
growlingOwl
growlingOwlā€¢2y ago
yeah, I think I'll enforce it, because the API's I am using do not return nulls
Accord
Accordā€¢2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.