Merge pull request #1361 from ecordell/application-problem-json

Return application/problem+json format errors
This commit is contained in:
Evan Cordell 2016-04-12 17:25:14 -04:00
commit 29eb0304e5
30 changed files with 309 additions and 141 deletions

View file

@ -124,7 +124,9 @@ angular.module('quay').factory('ApiService', ['Restangular', '$q', 'UtilService'
var deferred = $q.defer();
// If the error is a fresh login required, show the dialog.
if (resp.status == 401 && resp.data['error_type'] == 'fresh_login_required') {
// TODO: remove error_type (old style error)
var fresh_login_required = resp.data['title'] == 'fresh_login_required' || resp.data['error_type'] == 'fresh_login_required';
if (resp.status == 401 && fresh_login_required) {
var retryOperation = function() {
apiService[opName].apply(apiService, opArgs).then(function(resp) {
deferred.resolve(resp);
@ -293,7 +295,8 @@ angular.module('quay').factory('ApiService', ['Restangular', '$q', 'UtilService'
apiService.getErrorMessage = function(resp, defaultMessage) {
var message = defaultMessage;
if (resp['data']) {
message = resp['data']['error_message'] || resp['data']['message'] || resp['data']['error_description'] || message;
//TODO: remove error_message and error_description (old style error)
message = resp['data']['detail'] || resp['data']['error_message'] || resp['data']['message'] || resp['data']['error_description'] || message;
}
return message;

View file

@ -1,7 +1,7 @@
/**
* Service which provides helper methods for performing some simple UI operations.
*/
angular.module('quay').factory('UIService', ['$timeout', '$rootScope', '$location', function($timeout, $rootScope, $location) {
angular.module('quay').factory('UIService', ['$timeout', '$rootScope', '$location', 'ApiService', function($timeout, $rootScope, $location, ApiService) {
var CheckStateController = function(items, itemKey) {
this.items = items;
this.checked = [];
@ -12,6 +12,7 @@ angular.module('quay').factory('UIService', ['$timeout', '$rootScope', '$locatio
this.itemKey_ = itemKey;
this.listeners_ = [];
this.page_ = null;
this.ApiService = ApiService
};
CheckStateController.prototype.listen = function(callback) {
@ -138,7 +139,7 @@ angular.module('quay').factory('UIService', ['$timeout', '$rootScope', '$locatio
};
uiService.showFormError = function(elem, result, opt_placement) {
var message = result.data['message'] || result.data['error_description'] || '';
var message = ApiService.getErrorMessage(result, 'error');
if (message) {
uiService.showPopover(elem, message, opt_placement || 'bottom');
} else {