From 7273e8a713b726c0dca6acc6f447bdcafa9f25f0 Mon Sep 17 00:00:00 2001 From: Axel Pelerin Date: Wed, 8 Jan 2020 15:46:20 +0100 Subject: [PATCH] [caissedepargne] Raise ActionNeeded for error 401 on loans page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While loading to go to a loan's detail, an error 401 can appear saying: "Error 401: La situation actuelle de votre dossier ne vous permet pas d?accéder à cette fonctionnalité. Nous vous invitons à contacter votre Centre de relation Clientèle au : n° {0}." I can't find a way to pass this error to have the details, so I raise an ActionNeeded. There is no way to get the error message other than hardcode it in the raise. Closes: 14455@zendesk 46426@sibi --- modules/caissedepargne/pages.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/caissedepargne/pages.py b/modules/caissedepargne/pages.py index 6f1525e0a6..8e7f1d0f74 100644 --- a/modules/caissedepargne/pages.py +++ b/modules/caissedepargne/pages.py @@ -51,6 +51,7 @@ NoAccountsException, BrowserUnavailable, ActionNeeded, BrowserIncorrectPassword, ) from weboob.browser.filters.json import Dict +from weboob.browser.exceptions import ClientError def MyDecimal(*args, **kwargs): @@ -661,7 +662,13 @@ def get_loan_list(self): if 'JSESSIONID' in self.browser.session.cookies: # Need to delete this to access the consumer loans space (a new one will be created) del self.browser.session.cookies['JSESSIONID'] - self.go_loans_conso(tr) + try: + self.go_loans_conso(tr) + except ClientError as e: + if e.response.status_code == 401: + raise ActionNeeded('La situation actuelle de votre dossier ne vous permet pas d\'accéder à cette fonctionnalité. ' + 'Nous vous invitons à contacter votre Centre de relation Clientèle pour accéder à votre prêt.') + raise d = self.browser.loans_conso() if d: account.total_amount = float_to_decimal(d['contrat']['creditMaxAutorise']) -- GitLab