Fix API return codes
Created by: Xylakant
The API returns 404 for almost all error states. This PR introduces more appropriate return codes which makes it easier for client developers to distinguish between the specific errors.
Merge request reports
Activity
Created by: Xylakant
We're done here. All rests are passing, documentation is updated to match the actual behavior. Ready to review and (hopefully) merge.
By Administrator on 2013-02-27T17:38:36 (imported from GitLab project)
By Administrator on 2013-02-27T17:38:36 (imported from GitLab)
Unable to load the diff Created by: justahero
The idea was to have the delete function to be an idempotent function. When calling it with an invalid hook_id it should return a
200 Ok
status code, but the call to ProjectHook.find raises an exception if no hook is found.By Administrator on 2013-03-07T14:12:47 (imported from GitLab project)
By Administrator on 2013-03-07T14:12:47 (imported from GitLab)
Unable to load the diff Created by: justahero
Same as above, the call
error!
raises an Error and returns the status code given in parameter. Question is if status code422 Unprocessable Entity
is a good status code in this situation.By Administrator on 2013-03-07T14:12:47 (imported from GitLab project)
By Administrator on 2013-03-07T14:12:47 (imported from GitLab)
Created by: justahero
First of all thank you for your time, it is much appreciated.
A few words to the changes may give a better insight. Using the error helper functions from the
helpers.rb
file makes it easy to declare which status code should be returned. Nearly all helper functions use theerror!
function from Grape that when called raises an Error, causing the API function to return immediately. All other functions based onerror!
are also suffixed with exclamation mark!
to signal the same behaviour. This is useful when dealing with the4xx
status code range. The most notable change to the API functions is it to check if one or more of the required attributes of an API function is missing (required_attributes!
) raising a400 Bad Request
if it is the case.By Administrator on 2013-03-05T22:49:51 (imported from GitLab project)
By Administrator on 2013-03-05T22:49:51 (imported from GitLab)
Unable to load the diff