diff --git a/index.js b/index.js index 0e5078e45f9b4321cfbc22d95ebdca2941e26759..0c4aab22b96d0ded133fb81edf3664443caa73b6 100644 --- a/index.js +++ b/index.js @@ -297573,9 +297573,22 @@ function parseContracts(result) { function parseServiceId(result) { log('info', 'Parsing serviceId') const json = JSON.stringify(result) - return JSON.parse(json)['Envelope']['Body'][ - 'commanderCollectePublicationMesuresResponse' - ]['serviceSouscritId'] + const contractInfo = + JSON.parse(json)['Envelope']['Body'][ + 'commanderCollectePublicationMesuresResponse' + ] + if (contractInfo !== undefined) { + return contractInfo['serviceSouscritId'] + } else { + const errorMessage = + "No serviceSouscritId found, contract hasn't been created properly." + Sentry.captureException(errorMessage, { + tags: { + section: 'parseServiceId', + }, + }) + throw new Error(errorMessage) + } } /**