From 931976d254577ac4595e6d946024f9420836fee8 Mon Sep 17 00:00:00 2001
From: Bastien DUMONT <bdumont@grandlyon.com>
Date: Wed, 1 Feb 2023 14:02:18 +0100
Subject: [PATCH] fix: change errors for enedis routes

---
 src/core/contractActivation.js   | 4 ++--
 src/core/contractVerification.js | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/core/contractActivation.js b/src/core/contractActivation.js
index fe80491..aa24d51 100644
--- a/src/core/contractActivation.js
+++ b/src/core/contractActivation.js
@@ -47,7 +47,7 @@ async function activateContract(
     log('error', 'commanderCollectePublicationMesures')
     log('error', err)
     Sentry.captureException('commanderCollectePublicationMesures', err)
-    throw errors.LOGIN_FAILED
+    throw errors.CAPTCHA_RESOLUTION_FAILED
   })
 
   const parsedReply = await xml2js.parseStringPromise(response.body, {
@@ -71,7 +71,7 @@ async function activateContract(
     //TODO: handle SGT4B8: Il existe déjà plusieurs demandes en cours sur le point ?
     //TODO: handle SGT4H9: La demande ne porte pas sur un point équipé d'un compteur communicant ouvert aux services niveau 2.
     //TODO: handle SGT589: La demande ne peut pas aboutir car le compteur n'est actuellement pas téléopérable.
-    throw errors.LOGIN_FAILED
+    throw errors.CAPTCHA_RESOLUTION_FAILED
   }
 }
 
diff --git a/src/core/contractVerification.js b/src/core/contractVerification.js
index 8bc1c6f..6757f1b 100644
--- a/src/core/contractVerification.js
+++ b/src/core/contractVerification.js
@@ -34,7 +34,7 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
     log('error', 'rechercherServicesSouscritsMesures')
     log('error', err)
     Sentry.captureException('rechercherServicesSouscritsMesures', err)
-    throw errors.LOGIN_FAILED
+    throw errors.CAPTCHA_RESOLUTION_FAILED
   })
 
   const parsedReply = await xml2js.parseStringPromise(response.body, {
@@ -77,7 +77,7 @@ async function verifyContract(url, apiAuthKey, appLogin, contractId, pointId) {
       'error',
       'if an error is thrown here, it probably means that the contract has already been open today and that enedis cannot open a second one. Wait until tomorow to try again'
     )
-    throw errors.LOGIN_FAILED
+    throw errors.CAPTCHA_RESOLUTION_FAILED
   }
 }
 
-- 
GitLab