Handling the case when not 2xx response is desired #5280
-
When Kiota encounters an "Error" of some sort it throws an exception. This is a reflection of what the HTTP RFC says (section 10.4 of HTTP 1.1 rfc is "Client Error 4xx") but it is not a reflection of what clients intend. A case in point. You have a CRM type system with Dealers and Customers. In there you have Fine. But in my app, I have a forking code path whether or not a dealer has a relationship. If none exists, you have to prompt the dealer to get the permission of the client ... whatever. Kiota throws the 404, this means that my logic has to be handled using exception handling, which is generally an anti-pattern. Moreover, some languages (Type/javascript javascript) do not handle exceptions well enough in this situation that you can easily distinguish between 404 ... do this next ... and 500 ... PANIC!!! ... you can obviously do it, but not as cleanly as having multiple typed catches. One solution I can think of wrapping the kiota client's methods and return something Monadish ( But it occurs to me that there might be a better way. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I should also mention that using a filtered search |
Beta Was this translation helpful? Give feedback.
-
Hi @adamvandenhoven |
Beta Was this translation helpful? Give feedback.
🇨🇦🇨🇦🇨🇦🇨🇦
This is an opinionated decision we've made. In most languages dealing with an exception is more familiar to developers than monads or equivalent. And there's no way to tell a "good 400" from a "bad one" from the open API specification. So they should all be treated the same way.
Assuming the description describes this problem detail, the client will throw a problem details inst…