Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorReuben Pereira <rpereira@gitlab.com>2019-02-21 14:19:51 +0300
committerKamil TrzciƄski <ayufan@ayufan.eu>2019-02-21 14:19:51 +0300
commit536463295c2598505135bc61570ea66e1bad6496 (patch)
tree4bb61e295d682140d3c0cf8d9c3923e49e9e8e2b /app
parent56b82db63a91695a1dec1b7cbf39636bb01ad3df (diff)
Catch exception in calculate reactive cache
Return the exception as an error.
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/error_tracking/store/actions.js14
-rw-r--r--app/models/error_tracking/project_error_tracking_setting.rb6
-rw-r--r--app/services/error_tracking/list_issues_service.rb10
3 files changed, 22 insertions, 8 deletions
diff --git a/app/assets/javascripts/error_tracking/store/actions.js b/app/assets/javascripts/error_tracking/store/actions.js
index 2e192c958ba..11aec312368 100644
--- a/app/assets/javascripts/error_tracking/store/actions.js
+++ b/app/assets/javascripts/error_tracking/store/actions.js
@@ -2,7 +2,7 @@ import Service from '../services';
import * as types from './mutation_types';
import createFlash from '~/flash';
import Poll from '~/lib/utils/poll';
-import { __ } from '~/locale';
+import { __, sprintf } from '~/locale';
let eTagPoll;
@@ -19,9 +19,17 @@ export function startPolling({ commit }, endpoint) {
commit(types.SET_EXTERNAL_URL, data.external_url);
commit(types.SET_LOADING, false);
},
- errorCallback: () => {
+ errorCallback: response => {
+ let errorMessage = '';
+ if (response && response.data && response.data.message) {
+ errorMessage = response.data.message;
+ }
commit(types.SET_LOADING, false);
- createFlash(__('Failed to load errors from Sentry'));
+ createFlash(
+ sprintf(__(`Failed to load errors from Sentry. Error message: %{errorMessage}`), {
+ errorMessage,
+ }),
+ );
},
});
diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb
index 31084c54bdc..57283a78ea9 100644
--- a/app/models/error_tracking/project_error_tracking_setting.rb
+++ b/app/models/error_tracking/project_error_tracking_setting.rb
@@ -58,7 +58,7 @@ module ErrorTracking
def list_sentry_issues(opts = {})
with_reactive_cache('list_issues', opts.stringify_keys) do |result|
- { issues: result }
+ result
end
end
@@ -69,8 +69,10 @@ module ErrorTracking
def calculate_reactive_cache(request, opts)
case request
when 'list_issues'
- sentry_client.list_issues(**opts.symbolize_keys)
+ { issues: sentry_client.list_issues(**opts.symbolize_keys) }
end
+ rescue Sentry::Client::Error => e
+ { error: e.message }
end
# http://HOST/api/0/projects/ORG/PROJECT
diff --git a/app/services/error_tracking/list_issues_service.rb b/app/services/error_tracking/list_issues_service.rb
index 4cc35cfa4a8..a6c6bec9598 100644
--- a/app/services/error_tracking/list_issues_service.rb
+++ b/app/services/error_tracking/list_issues_service.rb
@@ -6,15 +6,19 @@ module ErrorTracking
DEFAULT_LIMIT = 20
def execute
- return error('not enabled') unless enabled?
- return error('access denied') unless can_read?
+ return error('Error Tracking is not enabled') unless enabled?
+ return error('Access denied', :unauthorized) unless can_read?
result = project_error_tracking_setting
.list_sentry_issues(issue_status: issue_status, limit: limit)
# our results are not yet ready
unless result
- return error('not ready', :no_content)
+ return error('Not ready. Try again later', :no_content)
+ end
+
+ if result[:error].present?
+ return error(result[:error], :bad_request)
end
success(issues: result[:issues])