summaryrefslogtreecommitdiff
path: root/lib/gitlab_access.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-02-11 23:43:57 +0100
committerDouwe Maan <douwe@gitlab.com>2015-02-11 23:43:57 +0100
commit562d7eb4ecaa9ca35f970567c0f09cdb29d26521 (patch)
tree032eb81a84675799500b5ecb54789fea90f3fcb6 /lib/gitlab_access.rb
parentf92a9c5a5f3f1cfc8a827abcf67a508133f39f04 (diff)
downloadgitlab-shell-562d7eb4ecaa9ca35f970567c0f09cdb29d26521.tar.gz
Show nice error message when internal API is unreachable.
Diffstat (limited to 'lib/gitlab_access.rb')
-rw-r--r--lib/gitlab_access.rb21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/gitlab_access.rb b/lib/gitlab_access.rb
index 547b81d..22343fd 100644
--- a/lib/gitlab_access.rb
+++ b/lib/gitlab_access.rb
@@ -18,15 +18,20 @@ class GitlabAccess
end
def exec
- status = api.check_access('git-receive-pack', @repo_name, @actor, @changes)
- if status.allowed?
- true
- else
- # reset GL_ID env since we stop git push here
- ENV['GL_ID'] = nil
- puts "GitLab: #{status.message}"
- false
+ begin
+ status = api.check_access('git-receive-pack', @repo_name, @actor, @changes)
+
+ return true if status.allowed?
+
+ message = status.message
+ rescue GitlabNet::ApiUnreachableError
+ message = "Failed to authorize your Git request: internal API unreachable"
end
+
+ # reset GL_ID env since we stop git push here
+ ENV['GL_ID'] = nil
+ puts "GitLab: #{message}"
+ false
end
protected