API: extracted helper method to provide 400 bad request error with description
Extracted a method for 400 error (Bad request) and adjusted code accordingly. The name of the missing attribute is used to show which one was missing from the request. It is used to give an appropriate message in the json response.
This commit is contained in:
parent
54ab9bb6df
commit
6fc3263e15
6 changed files with 28 additions and 17 deletions
|
@ -55,6 +55,12 @@ module Gitlab
|
|||
render_api_error!('403 Forbidden', 403)
|
||||
end
|
||||
|
||||
def bad_request!(attribute)
|
||||
message = ["400 (Bad request)"]
|
||||
message << "\"" + attribute.to_s + "\" not given"
|
||||
render_api_error!(message.join(' '), 400)
|
||||
end
|
||||
|
||||
def not_found!(resource = nil)
|
||||
message = ["404"]
|
||||
message << resource if resource
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue