summaryrefslogtreecommitdiff
path: root/lib/api/helpers.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-23 21:35:45 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-09-23 21:35:45 +0300
commitd0e3ab58260a19ccb82d6703ba6eb4942a4f297d (patch)
tree7acc39c7586acfcc12b0d1760905a37197dd626a /lib/api/helpers.rb
parent3c9ea7f4a90a4d3902b36a94678f6f39c1a1cc61 (diff)
parent998cd3cb63d56a0058c8e519d7c20e3d6e540899 (diff)
downloadgitlab-ce-d0e3ab58260a19ccb82d6703ba6eb4942a4f297d.tar.gz
Merge branch 'api/improve-error-reporting' of https://github.com/jubianchi/gitlabhq into jubianchi-api/improve-error-reporting
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r--lib/api/helpers.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 6af0f6d1b25..3a619169eca 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -155,7 +155,17 @@ module API
end
def not_allowed!
- render_api_error!('Method Not Allowed', 405)
+ render_api_error!('405 Method Not Allowed', 405)
+ end
+
+ def conflict!(message = nil)
+ render_api_error!(message || '409 Conflict', 409)
+ end
+
+ def render_validation_error!(model)
+ unless model.valid?
+ render_api_error!(model.errors.messages || '400 Bad Request', 400)
+ end
end
def render_api_error!(message, status)