summaryrefslogtreecommitdiff
path: root/lib/mattermost/session.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mattermost/session.rb')
-rw-r--r--lib/mattermost/session.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb
index f0ce51d6a71..e36500d24a3 100644
--- a/lib/mattermost/session.rb
+++ b/lib/mattermost/session.rb
@@ -1,10 +1,18 @@
module Mattermost
- class NoSessionError < StandardError
+ class Error < StandardError; end
+
+ class NoSessionError < Error
def message
'No session could be set up, is Mattermost configured with Single Sign on?'
end
end
+ class ConnectionError < Error
+ def message
+ 'Could not connect. Is Mattermost up?'
+ end
+ end
+
# This class' prime objective is to obtain a session token on a Mattermost
# instance with SSO configured where this GitLab instance is the provider.
#
@@ -66,10 +74,14 @@ module Mattermost
def get(path, options = {})
self.class.get(path, options.merge(headers: @headers))
+ rescue Errno::ECONNREFUSED
+ raise ConnectionError
end
def post(path, options = {})
self.class.post(path, options.merge(headers: @headers))
+ rescue Errno::ECONNREFUSED
+ raise ConnectionError
end
private