summaryrefslogtreecommitdiff
path: root/lib/gitlab_net.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_net.rb
parentf92a9c5a5f3f1cfc8a827abcf67a508133f39f04 (diff)
downloadgitlab-shell-562d7eb4ecaa9ca35f970567c0f09cdb29d26521.tar.gz
Show nice error message when internal API is unreachable.
Diffstat (limited to 'lib/gitlab_net.rb')
-rw-r--r--lib/gitlab_net.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index 88c7e75..6e76c98 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -7,6 +7,8 @@ require_relative 'gitlab_logger'
require_relative 'gitlab_access'
class GitlabNet
+ class ApiUnreachableError < StandardError; end
+
def check_access(cmd, repo, actor, changes)
project_name = repo.gsub("'", "")
project_name = project_name.gsub(/\.git\Z/, "")
@@ -97,7 +99,11 @@ class GitlabNet
http = http_client_for(uri)
request = http_request_for(method, uri, params)
- response = http.start { http.request(request) }
+ begin
+ response = http.start { http.request(request) }
+ rescue
+ raise ApiUnreachableError
+ end
if response.code == "200"
$logger.debug "Received response #{response.code} => <#{response.body}>."