How do you handle API errors [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
-5
down vote

favorite












When calling an API function, most of the times you either receive a success flag or an error message/object. (Some throw an exception). When the API does not throw exception do you generate application level exception or handle it with if/else structure?



My question is when your API either what it your way of handling such condition:



resposne=api.foo();

if(response!=truel)
return response.error;



or



resposne=api.foo();

if(response!=true)
throw exception (response.error);







share|improve this question











closed as off-topic by Stephen Rauch, Heslacher, Jamal♦ Jul 31 at 4:15


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – Stephen Rauch, Heslacher, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.












  • The code you presented in its current form is not meaningfully reviewable. We only review real, working code. If you edit your question to contain your actual code we can review it for improvements. See What topics can I ask about? for reference.
    – bruglesco
    Jul 31 at 2:55

















up vote
-5
down vote

favorite












When calling an API function, most of the times you either receive a success flag or an error message/object. (Some throw an exception). When the API does not throw exception do you generate application level exception or handle it with if/else structure?



My question is when your API either what it your way of handling such condition:



resposne=api.foo();

if(response!=truel)
return response.error;



or



resposne=api.foo();

if(response!=true)
throw exception (response.error);







share|improve this question











closed as off-topic by Stephen Rauch, Heslacher, Jamal♦ Jul 31 at 4:15


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – Stephen Rauch, Heslacher, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.












  • The code you presented in its current form is not meaningfully reviewable. We only review real, working code. If you edit your question to contain your actual code we can review it for improvements. See What topics can I ask about? for reference.
    – bruglesco
    Jul 31 at 2:55













up vote
-5
down vote

favorite









up vote
-5
down vote

favorite











When calling an API function, most of the times you either receive a success flag or an error message/object. (Some throw an exception). When the API does not throw exception do you generate application level exception or handle it with if/else structure?



My question is when your API either what it your way of handling such condition:



resposne=api.foo();

if(response!=truel)
return response.error;



or



resposne=api.foo();

if(response!=true)
throw exception (response.error);







share|improve this question











When calling an API function, most of the times you either receive a success flag or an error message/object. (Some throw an exception). When the API does not throw exception do you generate application level exception or handle it with if/else structure?



My question is when your API either what it your way of handling such condition:



resposne=api.foo();

if(response!=truel)
return response.error;



or



resposne=api.foo();

if(response!=true)
throw exception (response.error);









share|improve this question










share|improve this question




share|improve this question









asked Jul 31 at 1:26









PHPst

911




911




closed as off-topic by Stephen Rauch, Heslacher, Jamal♦ Jul 31 at 4:15


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – Stephen Rauch, Heslacher, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by Stephen Rauch, Heslacher, Jamal♦ Jul 31 at 4:15


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Lacks concrete context: Code Review requires concrete code from a project, with sufficient context for reviewers to understand how that code is used. Pseudocode, stub code, hypothetical code, obfuscated code, and generic best practices are outside the scope of this site." – Stephen Rauch, Heslacher, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.











  • The code you presented in its current form is not meaningfully reviewable. We only review real, working code. If you edit your question to contain your actual code we can review it for improvements. See What topics can I ask about? for reference.
    – bruglesco
    Jul 31 at 2:55

















  • The code you presented in its current form is not meaningfully reviewable. We only review real, working code. If you edit your question to contain your actual code we can review it for improvements. See What topics can I ask about? for reference.
    – bruglesco
    Jul 31 at 2:55
















The code you presented in its current form is not meaningfully reviewable. We only review real, working code. If you edit your question to contain your actual code we can review it for improvements. See What topics can I ask about? for reference.
– bruglesco
Jul 31 at 2:55





The code you presented in its current form is not meaningfully reviewable. We only review real, working code. If you edit your question to contain your actual code we can review it for improvements. See What topics can I ask about? for reference.
– bruglesco
Jul 31 at 2:55
















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Greedy Best First Search implementation in Rust

Function to Return a JSON Like Objects Using VBA Collections and Arrays

C++11 CLH Lock Implementation