Use ApiService to get error message
This commit is contained in:
parent
b5db41920f
commit
7c361c07f9
5 changed files with 8 additions and 4 deletions
|
@ -17,7 +17,7 @@ def error_view(error_type):
|
|||
@resource('/v1/error/<error_type>')
|
||||
@path_param('error_type', 'The error code identifying the type of error.')
|
||||
class Error(ApiResource):
|
||||
""" Resource for manging an organization's teams. """
|
||||
""" Resource for Error Descriptions"""
|
||||
schemas = {
|
||||
'ApiErrorDescription': {
|
||||
'type': 'object',
|
||||
|
|
|
@ -211,6 +211,7 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi
|
|||
|
||||
// Handle session expiration.
|
||||
Restangular.setErrorInterceptor(function(response) {
|
||||
//TODO: remove check for error_type (old style errors)
|
||||
var invalid_token = response.data['title'] == 'invalid_token' || response.data['error_type'] == 'invalid_token';
|
||||
if (response.status == 401 && invalid_token && response.data['session_required'] !== false) {
|
||||
$('#sessionexpiredModal').modal({});
|
||||
|
|
|
@ -46,7 +46,7 @@ angular.module('quay').directive('signupForm', function () {
|
|||
UserService.load();
|
||||
}, function(result) {
|
||||
$scope.registering = false;
|
||||
UIService.showFormError('#signupButton', result);
|
||||
UIService.showFormError('#signupButton', result, null, ApiService);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ angular.module('quay').factory('ApiService', ['Restangular', '$q', 'UtilService'
|
|||
var deferred = $q.defer();
|
||||
|
||||
// If the error is a fresh login required, show the dialog.
|
||||
// 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() {
|
||||
|
@ -294,6 +295,7 @@ angular.module('quay').factory('ApiService', ['Restangular', '$q', 'UtilService'
|
|||
apiService.getErrorMessage = function(resp, defaultMessage) {
|
||||
var message = defaultMessage;
|
||||
if (resp['data']) {
|
||||
//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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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'] || result.data['detail'] || '';
|
||||
var message = ApiService.getErrorMessage(result, 'error');
|
||||
if (message) {
|
||||
uiService.showPopover(elem, message, opt_placement || 'bottom');
|
||||
} else {
|
||||
|
|
Reference in a new issue