Skip to content

Commit

Permalink
feat: Only a warning when consumption or fetchEcheancier fail
Browse files Browse the repository at this point in the history
We have decided to have only a warning on this since it is possible to
have it fail with some valid contracts.
This still generates a warning log.
  • Loading branch information
doubleface authored and doubleface committed Feb 8, 2024
1 parent b718b57 commit 56851e9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,19 @@ class EdfContentScript extends ContentScript {
run: () => this.fetchBillsForAllContracts(contracts, context),
selectorToWait: '#facture, #factureSelection'
})
const echeancierResult = await this.withRetry({
label: 'fetchEcheancierBills',
run: () => this.fetchEcheancierBills(contracts, context),
selectorToWait: `.timeline-header__download, a.accessPage[href*='factures-et-paiements.html']`
})
let echeancierResult
try {
echeancierResult = await this.withRetry({
label: 'fetchEcheancierBills',
run: () => this.fetchEcheancierBills(contracts, context),
selectorToWait: `.timeline-header__download, a.accessPage[href*='factures-et-paiements.html']`
})
} catch (err) {
this.log(
'warn',
`Got an error while fetching housing data: ${err.message}`
)
}

// fetch the housing data only if we do not have an existing identity or if the existing
// identity is older than 1 month
Expand Down Expand Up @@ -381,10 +389,9 @@ class EdfContentScript extends ContentScript {
await this.saveIdentity(identity)
} catch (err) {
this.log(
'error',
'warn',
`Got an error while fetching housing data: ${err.message}`
)
throw new Error('UNKNOWN_ERROR.PARTIAL_SYNC')
}
} else {
this.log(
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export function formatHousing(
10
),
[energyType + '_consumptions']: consumptions[energyType],
charging_type: echeancierResult.isMonthly ? 'monthly' : 'yearly'
charging_type: echeancierResult?.isMonthly ? 'monthly' : 'yearly'
}

// even if the api does not show it, real pdl number for gas is pce_number
Expand Down

0 comments on commit 56851e9

Please sign in to comment.