summaryrefslogtreecommitdiff
path: root/lib/mattermost/team.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-12-19 23:53:19 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2016-12-19 23:56:21 +0100
commit34295036e2a9ecf18ca5440a5dd6dbb0c7f05643 (patch)
treea529cbc332882305520c7650cbe860301e12abb8 /lib/mattermost/team.rb
parent921f411a41d92ff6b3fdea2560adbd861d97be57 (diff)
downloadgitlab-ce-34295036e2a9ecf18ca5440a5dd6dbb0c7f05643.tar.gz
Improve sources
- Add proper error handling, - Use flash[:alert] and flash[:notice], - Use `resource` instead of `resources`,
Diffstat (limited to 'lib/mattermost/team.rb')
-rw-r--r--lib/mattermost/team.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb
index 5ee77aa9adf..2de01eced0b 100644
--- a/lib/mattermost/team.rb
+++ b/lib/mattermost/team.rb
@@ -1,7 +1,15 @@
module Mattermost
class Team
def self.all(session)
- session.get('/api/v3/teams/all').parsed_response
+ response = session.get('/api/v3/teams/all')
+
+ if response.success?
+ response.parsed_response
+ elsif response.parsed_response.try(:has_key?, 'message')
+ raise response.parsed_response['message']
+ else
+ raise 'Failed to list teams'
+ end
end
end
end