summaryrefslogtreecommitdiff
path: root/lib/mattermost/client.rb
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-12-20 19:11:53 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2016-12-20 19:11:53 +0100
commit61d09a7b15ef9ae2e23359f1afb87b0adbda4dd4 (patch)
tree1cfeb2ebdd16c9972ad296416a4db48c30cc7637 /lib/mattermost/client.rb
parent0cf23fde7c666b64e6c18a92d29e632f51b00059 (diff)
downloadgitlab-ce-61d09a7b15ef9ae2e23359f1afb87b0adbda4dd4.tar.gz
WIP
Diffstat (limited to 'lib/mattermost/client.rb')
-rw-r--r--lib/mattermost/client.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/mattermost/client.rb b/lib/mattermost/client.rb
index d6759eac0d0..6eaaed34063 100644
--- a/lib/mattermost/client.rb
+++ b/lib/mattermost/client.rb
@@ -29,13 +29,13 @@ module Mattermost
def json_response(response)
json_response = JSON.parse(response.body)
- if response.success?
- json_response
- elsif json_response['message']
- raise ClientError(json_response['message'])
- else
- raise ClientError('Undefined error')
+ unless response.success?
+ raise ClientError(json_response['message'] || 'Undefined error')
end
+
+ json_response
+ rescue JSON::JSONError => e
+ raise ClientError('Cannot parse response')
end
end
end