diff options
| author | Damien Bouvy <dbo@odoo.com> | 2019-08-16 14:10:03 +0000 |
|---|---|---|
| committer | Damien Bouvy <dbo@odoo.com> | 2019-08-16 15:52:40 +0000 |
| commit | 5193f0d010f5cd3bf4ccc5c7e39aff3fdacdd111 (patch) | |
| tree | 79b8aca8522478895b2355b9b4c91462b2b9728c /addons | |
| parent | c284bda4b0e48577998f67ed93ea0c61e1cfabf1 (diff) | |
[IMP] payment*: better handling of error message
Sometimes there's a title + content, sometimes not; reading the message
itself usually yields a None somewhere which is fugly.
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/payment/static/src/js/payment_form.js | 12 | ||||
| -rw-r--r-- | addons/payment_authorize/static/src/js/payment_form.js | 2 | ||||
| -rw-r--r-- | addons/payment_stripe/static/src/js/payment_form.js | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/addons/payment/static/src/js/payment_form.js b/addons/payment/static/src/js/payment_form.js index 9f4893275ad..0085242483d 100644 --- a/addons/payment/static/src/js/payment_form.js +++ b/addons/payment/static/src/js/payment_form.js @@ -139,6 +139,12 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ $(button).children('.fa').addClass('fa-lock'); $(button).find('span.o_loader').remove(); }, + _parseError: function(e) { + if (e.message.data.arguments[1]) { + return e.message.data.arguments[0] + e.message.data.arguments[1]; + } + return e.message.data.arguments[0]; + }, //-------------------------------------------------------------------------- // Handlers @@ -246,7 +252,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ self.displayError( _t('Server Error'), _t("We are not able to add your payment method at the moment.") + - error.message.data.message + this._parseError(error) ); }); } @@ -296,7 +302,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ self.displayError( _t('Server Error'), _t("We are not able to redirect you to the payment form. ") + - error.message.data.message + this._parseError(error) ); }); } @@ -428,7 +434,7 @@ publicWidget.registry.PaymentForm = publicWidget.Widget.extend({ self.displayError( _t('Server error'), _t("We are not able to add your payment method at the moment.</p>") + - error.message.data.message + this._parseError(error) ); }); } diff --git a/addons/payment_authorize/static/src/js/payment_form.js b/addons/payment_authorize/static/src/js/payment_form.js index 11eda20b21d..d5d02a696c7 100644 --- a/addons/payment_authorize/static/src/js/payment_form.js +++ b/addons/payment_authorize/static/src/js/payment_form.js @@ -78,7 +78,7 @@ PaymentForm.include({ self.displayError( _t('Server Error'), _t("We are not able to add your payment method at the moment.") + - error.message.data.message + this._parseError(error) ); }); }; diff --git a/addons/payment_stripe/static/src/js/payment_form.js b/addons/payment_stripe/static/src/js/payment_form.js index c3d77bf4b7a..e66fe0ebfb3 100644 --- a/addons/payment_stripe/static/src/js/payment_form.js +++ b/addons/payment_stripe/static/src/js/payment_form.js @@ -84,7 +84,7 @@ PaymentForm.include({ self.displayError( _t('Unable to save card'), _t("We are not able to add your payment method at the moment. ") + - error.message.data.message + this._parseError(error) ); }); }, |
