Commit a02a8b88 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

feat(dacc): add better error handling

parent 47c3b515
...@@ -38,6 +38,9 @@ interface Indicator { ...@@ -38,6 +38,9 @@ interface Indicator {
// Store all id of events read during the process // Store all id of events read during the process
const readUsageEvents: UsageEvent[] = [] const readUsageEvents: UsageEvent[] = []
// Store error events
const errorEvent: { error: any; doctype: string }[] = []
const sendIndicator = async ( const sendIndicator = async (
indicator: Indicator, indicator: Indicator,
client: Client client: Client
...@@ -943,6 +946,17 @@ const AggregatorUsageEvents = async ({ ...@@ -943,6 +946,17 @@ const AggregatorUsageEvents = async ({
client, client,
uniqueReadUsageEvents uniqueReadUsageEvents
) )
if (errorEvent.length > 0) {
// Build error
let error = `Process end with ${errorEvent.length} errors : `
errorEvent.forEach(el => {
error += `${el.doctype}, `
})
log('error', error)
throw error
}
log('info', 'End of service') log('info', 'End of service')
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment