c# - Handling return value from Web Service Call Wrapper -


I created this method below, which makes an HTTP call to a third party API, I want to have feedback on handling the way if the call fails, then only I need to return ExistsInList bool values ​​if the response is not zero. But in the last return statement, do I necessarily select any other response = Response == will not be empty? Incorrect: Select Response. Axis Innist; Like the previous return in the catches to check zero already?

The way I am reaching it, it looks redundant and I do not know that I really am the last person but I say yes, because you always do not trust the response to give a valid response. Can, even if no mistake has happened.

  Public Stable Bull UserExistsInList (string email, string listID) {SelectRecipientRequest selectRequest = new selector request (email, listID); Select Respective Space Select Response = Null; Select {SelectResponse = (SelectRecipientResponse). Request Send configuration (); } Hold (exception) {return choice response == is empty? Incorrect: Select Response. Axis Innist; } Return Select Response. Axis Innist; }  

Tip # 1: Exceptions do not! You do not know what kind of exceptions you are ignoring. You are assuming that any exception at that point indicates a problem with the third-party API, but this can not happen.

My suggestion is to log on to the least exception and then ignore it to be sure to see the log during development so you can see what type of exception you get Are there. To understand the code in wrappers, understand how you can get exceptions (or rather, which means something has been done, like communication failure).

Then, the only exception to this code which indicates a problem with the API, the rest should be allowed for promotion, handled by the code, which is to be handled by them, or handled by the code. , Which will log on them correctly.

For an example of someone who "cleans with code like this."


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -