diff --git a/index.js b/index.js index dc0abf3a3a68be2a856e23934f6bbfd638c66abe..22905f0fbbd3d17ac0191a062fb18da767b99dc5 100644 --- a/index.js +++ b/index.js @@ -196,7 +196,6 @@ async function start(fields, cozyParameters, doRetry = true) { fields.access_token = body.attributes.oauth.access_token return start(fields, cozyParameters, false) } - log('error', `Error during authentication: ${err.message}`) throw errors.VENDOR_DOWN } else { @@ -251,8 +250,19 @@ async function getLoadData(token, usagePointID) { Authorization: 'Bearer ' + token } } - const response = await rp(dataRequest) - return response + try { + const response = await rp(dataRequest) + return response + } catch (err) { + if (err.statusCode === 404 || err.code === 404) { + log('warning', 'caught an 404 error') + log('warning', err.message) + log('warning', err) + return null + } else { + throw err + } + } } /**