diff options
| author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-08-15 17:27:22 +0300 | 
|---|---|---|
| committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-08-15 17:27:22 +0300 | 
| commit | 5e95c0b8d201a6bfdd020aa29a5a6e14c7085e3f (patch) | |
| tree | 5e221b64c68dfbe5c6cb026b7ac92065104342f1 /lib/api/api.rb | |
| parent | 94a7198ade54595d72797cab09db2c2a89172535 (diff) | |
| parent | 6af598fc173bd0f7cd4237fa3e60d223103301a3 (diff) | |
| download | gitlab-ce-5e95c0b8d201a6bfdd020aa29a5a6e14c7085e3f.tar.gz | |
Merge branch 'master' into dz-merge-request-version
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'lib/api/api.rb')
| -rw-r--r-- | lib/api/api.rb | 14 | 
1 files changed, 10 insertions, 4 deletions
| diff --git a/lib/api/api.rb b/lib/api/api.rb index 9d8f297191f..aa34110c34b 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -3,12 +3,18 @@ module API      include APIGuard      version 'v3', using: :path +    rescue_from Gitlab::Access::AccessDeniedError do +      rack_response({ 'message' => '403 Forbidden' }.to_json, 403) +    end +      rescue_from ActiveRecord::RecordNotFound do        rack_response({ 'message' => '404 Not found' }.to_json, 404)      end -    rescue_from Grape::Exceptions::ValidationErrors do |e| -      error!({ messages: e.full_messages }, 400) +    # Retain 405 error rather than a 500 error for Grape 0.15.0+. +    # See: https://github.com/ruby-grape/grape/commit/252bfd27c320466ec3c0751812cf44245e97e5de +    rescue_from Grape::Exceptions::Base do |e| +      error! e.message, e.status, e.headers      end      rescue_from :all do |exception| @@ -30,6 +36,7 @@ module API      # Ensure the namespace is right, otherwise we might load Grape::API::Helpers      helpers ::API::Helpers +    mount ::API::AccessRequests      mount ::API::AwardEmoji      mount ::API::Branches      mount ::API::Builds @@ -38,19 +45,18 @@ module API      mount ::API::DeployKeys      mount ::API::Environments      mount ::API::Files -    mount ::API::GroupMembers      mount ::API::Groups      mount ::API::Internal      mount ::API::Issues      mount ::API::Keys      mount ::API::Labels      mount ::API::LicenseTemplates +    mount ::API::Members      mount ::API::MergeRequests      mount ::API::Milestones      mount ::API::Namespaces      mount ::API::Notes      mount ::API::ProjectHooks -    mount ::API::ProjectMembers      mount ::API::ProjectSnippets      mount ::API::Projects      mount ::API::Repositories | 
