Skip to content
Snippets Groups Projects
Commit 4d2806a9 authored by Bastien DUMONT's avatar Bastien DUMONT :angel:
Browse files

fix: handle passerelle down

parent 29e3c848
No related branches found
No related tags found
1 merge request!46fix: handle passerelle down
......@@ -32,50 +32,60 @@ async function findUserPdl(
apikey: apiAuthKey,
}
const { response } = await soapRequest({
url: url,
headers: sgeHeaders,
xml: rechercherPoint(
appLogin,
lastname,
postalCode,
inseeCode,
address,
escalierEtEtageEtAppartement
),
}).catch(err => {
const errorMessage = 'Error while finding user pdl : ' + err.message
log('error', errorMessage)
Sentry.captureException(errorMessage, {
try {
const { response } = await soapRequest({
url: url,
headers: sgeHeaders,
xml: rechercherPoint(
appLogin,
lastname,
postalCode,
inseeCode,
address,
escalierEtEtageEtAppartement
),
}).catch(err => {
const errorMessage = 'Error while finding user pdl : ' + err.message
log('error', errorMessage)
Sentry.captureException(errorMessage, {
tags: {
section: 'findUserPdl',
},
extra: {
address: address,
postalCode: postalCode,
escalierEtEtageEtAppartement: escalierEtEtageEtAppartement,
},
})
throw new Error(errors.VENDOR_DOWN)
})
const parsedReply = await xml2js.parseStringPromise(response.body, {
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
})
try {
return parseUserPdl(parsedReply)
} catch (error) {
log('warn', 'Error while parsing user PDL: ' + error)
if (parsedReply.Envelope.Body.Fault) {
log(
'warn',
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
}
return null
}
} catch (error) {
log('error', 'Error while findingUserPdl', error)
Sentry.captureException(error, {
tags: {
section: 'findUserPdl',
},
extra: {
address: address,
postalCode: postalCode,
escalierEtEtageEtAppartement: escalierEtEtageEtAppartement,
},
})
throw new Error(errors.VENDOR_DOWN)
})
const parsedReply = await xml2js.parseStringPromise(response.body, {
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
})
try {
return parseUserPdl(parsedReply)
} catch (error) {
log('warn', 'Error while parsing user PDL: ' + error)
if (parsedReply.Envelope.Body.Fault) {
log(
'warn',
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
}
return null
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment