diff options
author | Alex Denisov <1101.debian@gmail.com> | 2012-09-10 14:49:00 +0400 |
---|---|---|
committer | Alex Denisov <1101.debian@gmail.com> | 2012-09-10 14:49:00 +0400 |
commit | a065557208d6076ec869144346e06c7de714389c (patch) | |
tree | 4c281f085d048e1defdcc45c8cebb57f13e465b8 /lib/api/helpers.rb | |
parent | 915dac0055cd801c080ebcd37749f4fc6d2d12c4 (diff) |
Common errors method added
Diffstat (limited to 'lib/api/helpers.rb')
-rw-r--r-- | lib/api/helpers.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 3a385f1582a..054eb2d3f70 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -31,22 +31,26 @@ module Gitlab # error helpers def forbidden! - error!({'message' => '403 Forbidden'}, 403) + render_api_error!('403 Forbidden', 403) end def not_found!(resource = nil) message = ["404"] message << resource if resource message << "Not Found" - error!({'message' => message.join(' ')}, 404) + render_api_error!(message.join(' '), 404) end def unauthorized! - error!({'message' => '401 Unauthorized'}, 401) + render_api_error!('401 Unauthorized', 401) end def not_allowed! - error!({'message' => 'method not allowed'}, 405) + render_api_error!('Method Not Allowed', 405) + end + + def render_api_error!(message, status) + error!({'message' => message}, status) end private |