summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-16 12:09:53 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-16 12:09:53 +0000
commit5a2284f3500088e04cf3a5854fb06dc9db2b6077 (patch)
treed8dc0c1b24a31de47d81cf6771504bd439b20625 /lib/api/helpers.rb
parenta11e5bac528dd5c84e19acb3db1b8addd698726e (diff)
downloadgitlab-ce-5a2284f3500088e04cf3a5854fb06dc9db2b6077.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 2941150128a..6fe25471289 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -322,7 +322,7 @@ module API
# keys (required) - A hash consisting of keys that must be present
def required_attributes!(keys)
keys.each do |key|
- bad_request!(key) unless params[key].present?
+ bad_request_missing_attribute!(key) unless params[key].present?
end
end
@@ -368,12 +368,16 @@ module API
render_api_error!(message.join(' '), 403)
end
- def bad_request!(attribute)
- message = ["400 (Bad request)"]
- message << "\"" + attribute.to_s + "\" not given" if attribute
+ def bad_request!(reason = nil)
+ message = ['400 Bad request']
+ message << "- #{reason}" if reason
render_api_error!(message.join(' '), 400)
end
+ def bad_request_missing_attribute!(attribute)
+ bad_request!("\"#{attribute}\" not given")
+ end
+
def not_found!(resource = nil)
message = ["404"]
message << resource if resource