How do you handle API errors [closed]
Clash 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);
api exception
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
add a comment |Â
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);
api exception
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
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
add a comment |Â
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);
api exception
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);
api exception
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
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
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
add a comment |Â
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
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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