diff options
author | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-13 15:48:52 +0100 |
---|---|---|
committer | Sebastian Ziebell <sebastian.ziebell@asquera.de> | 2013-02-13 15:48:52 +0100 |
commit | 6fc3263e15b71830e6f1b2a66891da5f4c055137 (patch) | |
tree | f46179ab65e682b260ab3ce09a83ce1d3988b153 /lib/api/helpers.rb | |
parent | 54ab9bb6df3a2cd9f9384aebae07e0b18acee10b (diff) | |
download | gitlab-ce-6fc3263e15b71830e6f1b2a66891da5f4c055137.tar.gz |
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.
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 6bd8111c2b2..becb3bce5b0 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -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 |