diff --git a/src/app/directives/apiFormDirective.js b/src/app/directives/apiFormDirective.js index a2049c2a1f..b1842cf2e4 100644 --- a/src/app/directives/apiFormDirective.js +++ b/src/app/directives/apiFormDirective.js @@ -31,7 +31,12 @@ angular }, function failure(reason) { $timeout(function () { form.$loading = false; - validationService.addErrors(form, reason); + if (typeof reason === 'string') { + validationService.addError(form, null, reason, true); + } + else { + validationService.addErrors(form, reason); + } scope.$broadcast('show-errors-check-validity'); $('html, body').animate({ scrollTop: 0 }, 200); }); diff --git a/src/app/settings/settingsPremiumController.js b/src/app/settings/settingsPremiumController.js index 618ae099d7..b8781a5c60 100644 --- a/src/app/settings/settingsPremiumController.js +++ b/src/app/settings/settingsPremiumController.js @@ -56,12 +56,18 @@ $scope.submit = function (model) { $scope.submitPromise = getPaymentToken(model).then(function (token) { + if (!token) { + throw 'No payment token.'; + } + var request = { paymentToken: token, additionalStorageGb: model.additionalStorageGb }; return apiService.accounts.postPremium(request).$promise; + }, function (err) { + throw err; }).then(function (result) { return authService.updateProfilePremium(true); }).then(function () { @@ -78,6 +84,8 @@ if ($scope.paymentMethod === 'paypal') { return btInstance.requestPaymentMethod().then(function (payload) { return payload.nonce; + }).catch(function (err) { + throw err.message; }); } else {