loduis / teamwork.com-project-management

PHP API for Teamwork.com
https://developer.teamwork.com/
MIT License
70 stars 59 forks source link

throw catchable exception instead of exit in JSON response #46

Closed nexxome closed 5 years ago

nexxome commented 5 years ago

Hi, it would be awesome if the JSON response throws an exception on other response status codes instead of exit because then you can catch it and proceed with code execution.

Thanks

nexxome commented 5 years ago

The XML response always throws an exception on error, the JSON response doesn't. If I have multiple requests and one will fail, then the application just exits and there is no way to prevent this. If it would throw an exception instead, you can respond to it:


try {
    $response = $timeModel->getByProject($projectId);
}catch (\Exception $e){
    ...
}
simonschaufi commented 5 years ago

I know the user can do that but what if he doesn't? If people rely on this behavior, this looks like a breaking change to me, or?

nexxome commented 5 years ago

How can anybody rely on a behavior on which you can't respond to?

simonschaufi commented 5 years ago

good question. I will then just merge it like that and hope nobody will complain later on :D