diff options
Diffstat (limited to 'app/models/error_tracking/project_error_tracking_setting.rb')
-rw-r--r-- | app/models/error_tracking/project_error_tracking_setting.rb | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb index 31084c54bdc..892eef8eb99 100644 --- a/app/models/error_tracking/project_error_tracking_setting.rb +++ b/app/models/error_tracking/project_error_tracking_setting.rb @@ -40,6 +40,8 @@ module ErrorTracking end def self.build_api_url_from(api_host:, project_slug:, organization_slug:) + return if api_host.blank? + uri = Addressable::URI.parse("#{api_host}/api/0/projects/#{organization_slug}/#{project_slug}/") uri.path = uri.path.squeeze('/') @@ -63,13 +65,29 @@ module ErrorTracking end def list_sentry_projects - { projects: sentry_client.list_projects } + with_reactive_cache('list_projects', {}) do |result| + result + end end def calculate_reactive_cache(request, opts) case request when 'list_issues' sentry_client.list_issues(**opts.symbolize_keys) + when 'list_projects' + begin + { projects: sentry_client.list_projects } + rescue Sentry::Client::SentryError => e + { + error: e.message, + http_status: :unprocessable_entity + } + rescue Sentry::Client::Error => e + { + error: e.message, + http_status: :bad_request + } + end end end |