diff options
author | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-04-06 13:42:18 +0100 |
---|---|---|
committer | Luke "Jared" Bennett <lbennett@gitlab.com> | 2017-04-06 13:42:18 +0100 |
commit | 66d03aae98cc0429d2ed75eac68025f447868479 (patch) | |
tree | 859cef0576726f1ecd7a6c0d4bc14c560ebe4f84 /app/assets/javascripts | |
parent | 98f59fc20fdab2e4d0f8f06d615abb3922d766cb (diff) | |
download | gitlab-ce-66d03aae98cc0429d2ed75eac68025f447868479.tar.gz |
Fixed error handling
Diffstat (limited to 'app/assets/javascripts')
4 files changed, 16 insertions, 8 deletions
diff --git a/app/assets/javascripts/droplab/plugins/ajax.js b/app/assets/javascripts/droplab/plugins/ajax.js index f08b638fc62..12afe53ed76 100644 --- a/app/assets/javascripts/droplab/plugins/ajax.js +++ b/app/assets/javascripts/droplab/plugins/ajax.js @@ -1,9 +1,5 @@ /* eslint-disable */ -function droplabAjaxException(message) { - this.message = message; -} - const Ajax = { _loadUrlData: function _loadUrlData(url) { var self = this; @@ -58,9 +54,7 @@ const Ajax = { this._loadUrlData(config.endpoint) .then(function(d) { self._loadData(d, config, self); - }, config.onError).catch(function(e) { - throw new droplabAjaxException(e.message || e); - }); + }, config.onError).catch(config.onError); } }, destroy: function() { diff --git a/app/assets/javascripts/droplab/plugins/ajax_filter.js b/app/assets/javascripts/droplab/plugins/ajax_filter.js index 7fe221e101f..cfd7e2ca189 100644 --- a/app/assets/javascripts/droplab/plugins/ajax_filter.js +++ b/app/assets/javascripts/droplab/plugins/ajax_filter.js @@ -68,7 +68,7 @@ const AjaxFilter = { this._loadUrlData(url) .then(function(data) { self._loadData(data, config, self); - }, config.onError); + }, config.onError).catch(config.onError); } }, diff --git a/app/assets/javascripts/filtered_search/dropdown_non_user.js b/app/assets/javascripts/filtered_search/dropdown_non_user.js index 35c76dff79a..6296965b911 100644 --- a/app/assets/javascripts/filtered_search/dropdown_non_user.js +++ b/app/assets/javascripts/filtered_search/dropdown_non_user.js @@ -1,3 +1,5 @@ +/* global Flash */ + import Ajax from '~/droplab/plugins/ajax'; import Filter from '~/droplab/plugins/filter'; @@ -13,6 +15,11 @@ require('./filtered_search_dropdown'); endpoint, method: 'setData', loadingTemplate: this.loadingTemplate, + onError() { + /* eslint-disable no-new */ + new Flash('An error occured fetching the dropdown data.'); + /* eslint-enable no-new */ + }, }, Filter: { filterFunction: gl.DropdownUtils.filterWithSymbol.bind(null, this.symbol, input), diff --git a/app/assets/javascripts/filtered_search/dropdown_user.js b/app/assets/javascripts/filtered_search/dropdown_user.js index 4f9f25c1f1b..38b5d315bcf 100644 --- a/app/assets/javascripts/filtered_search/dropdown_user.js +++ b/app/assets/javascripts/filtered_search/dropdown_user.js @@ -1,3 +1,5 @@ +/* global Flash */ + import AjaxFilter from '~/droplab/plugins/ajax_filter'; require('./filtered_search_dropdown'); @@ -18,6 +20,11 @@ require('./filtered_search_dropdown'); }, searchValueFunction: this.getSearchInput.bind(this), loadingTemplate: this.loadingTemplate, + onError() { + /* eslint-disable no-new */ + new Flash('An error occured fetching the dropdown data.'); + /* eslint-enable no-new */ + }, }, }; } |