diff options
Diffstat (limited to 'lib/mattermost')
-rw-r--r-- | lib/mattermost/client.rb | 8 | ||||
-rw-r--r-- | lib/mattermost/error.rb | 5 | ||||
-rw-r--r-- | lib/mattermost/session.rb | 16 |
3 files changed, 12 insertions, 17 deletions
diff --git a/lib/mattermost/client.rb b/lib/mattermost/client.rb index 7fb959a149c..a5c1f788c68 100644 --- a/lib/mattermost/client.rb +++ b/lib/mattermost/client.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Mattermost - ClientError = Class.new(Mattermost::Error) + ClientError = Class.new(::Mattermost::Error) class Client attr_reader :user @@ -11,7 +11,7 @@ module Mattermost end def with_session(&blk) - Mattermost::Session.new(user).with_session(&blk) + ::Mattermost::Session.new(user).with_session(&blk) end private @@ -52,12 +52,12 @@ module Mattermost json_response = Gitlab::Json.parse(response.body, legacy_mode: true) unless response.success? - raise Mattermost::ClientError, json_response['message'] || 'Undefined error' + raise ::Mattermost::ClientError, json_response['message'] || 'Undefined error' end json_response rescue JSON::JSONError - raise Mattermost::ClientError, 'Cannot parse response' + raise ::Mattermost::ClientError, 'Cannot parse response' end end end diff --git a/lib/mattermost/error.rb b/lib/mattermost/error.rb deleted file mode 100644 index 054bd5457bd..00000000000 --- a/lib/mattermost/error.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -module Mattermost - Error = Class.new(StandardError) -end diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb index 523d82f9161..9374c5c8f8f 100644 --- a/lib/mattermost/session.rb +++ b/lib/mattermost/session.rb @@ -1,13 +1,13 @@ # frozen_string_literal: true module Mattermost - class NoSessionError < Mattermost::Error + class NoSessionError < ::Mattermost::Error def message 'No session could be set up, is Mattermost configured with Single Sign On?' end end - ConnectionError = Class.new(Mattermost::Error) + ConnectionError = Class.new(::Mattermost::Error) # This class' prime objective is to obtain a session token on a Mattermost # instance with SSO configured where this GitLab instance is the provider. @@ -42,7 +42,7 @@ module Mattermost yield self rescue Errno::ECONNREFUSED => e Gitlab::AppLogger.error(e.message + "\n" + e.backtrace.join("\n")) - raise Mattermost::NoSessionError + raise ::Mattermost::NoSessionError ensure destroy end @@ -100,11 +100,11 @@ module Mattermost end def create - raise Mattermost::NoSessionError unless oauth_uri - raise Mattermost::NoSessionError unless token_uri + raise ::Mattermost::NoSessionError unless oauth_uri + raise ::Mattermost::NoSessionError unless token_uri @token = request_token - raise Mattermost::NoSessionError unless @token + raise ::Mattermost::NoSessionError unless @token @headers = { Authorization: "Bearer #{@token}" @@ -174,9 +174,9 @@ module Mattermost def handle_exceptions yield rescue Gitlab::HTTP::Error => e - raise Mattermost::ConnectionError, e.message + raise ::Mattermost::ConnectionError, e.message rescue Errno::ECONNREFUSED => e - raise Mattermost::ConnectionError, e.message + raise ::Mattermost::ConnectionError, e.message end def parse_cookie(response) |