diff --git a/src/helpers/parsing.js b/src/helpers/parsing.js index af11ce21e28ce99bc0b528f2bce1b8cf16d99e4a..caffed89dc715f5a1525b2e2aa691a405e840759 100644 --- a/src/helpers/parsing.js +++ b/src/helpers/parsing.js @@ -75,9 +75,17 @@ 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 { + throw new Error( + "No serviceSouscritId found, contract hasn't been created properly." + ) + } } /**