diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-12 00:06:21 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-12 00:06:21 +0000 |
commit | 75687c79df805b57914d79cf217e3f08dbc77cc2 (patch) | |
tree | bff07aefc6467b8a7e00cd7649109fc6e8b7768f /lib/sentry | |
parent | 0c3f12149372a79b825d265a6c28dc547e4a1afc (diff) | |
download | gitlab-ce-75687c79df805b57914d79cf217e3f08dbc77cc2.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/sentry')
-rw-r--r-- | lib/sentry/client.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/sentry/client.rb b/lib/sentry/client.rb index f16df0dde4f..15158bbc3b5 100644 --- a/lib/sentry/client.rb +++ b/lib/sentry/client.rb @@ -4,6 +4,7 @@ module Sentry class Client Error = Class.new(StandardError) MissingKeysError = Class.new(StandardError) + ResponseInvalidSizeError = Class.new(StandardError) attr_accessor :url, :token @@ -27,6 +28,8 @@ module Sentry def list_issues(issue_status:, limit:) issues = get_issues(issue_status: issue_status, limit: limit) + validate_size(issues) + handle_mapping_exceptions do map_to_errors(issues) end @@ -42,6 +45,16 @@ module Sentry private + def validate_size(issues) + return if Gitlab::Utils::DeepSize.new(issues).valid? + + raise Client::ResponseInvalidSizeError, "Sentry API response is too big. Limit is #{Gitlab::Utils::DeepSize.human_default_max_size}." + end + + def valid_size?(issues) + Gitlab::Utils::DeepSize.new(issues).valid? + end + def handle_mapping_exceptions(&block) yield rescue KeyError => e @@ -108,7 +121,7 @@ module Sentry raise_error "Sentry response status code: #{response.code}" end - response + response.parsed_response end def raise_error(message) |