mirror of
https://github.com/twentyhq/twenty
synced 2026-04-21 13:37:22 +00:00
add error logs
This commit is contained in:
parent
0f01877120
commit
7bde1bae1f
7 changed files with 23 additions and 7 deletions
|
|
@ -16,7 +16,11 @@ export type ForEachPageOptions = {
|
|||
onCursorAdvance?: (cursor: string) => Promise<void>;
|
||||
};
|
||||
|
||||
export type OnPageResult = { ok: boolean; stop?: boolean };
|
||||
export type OnPageResult = {
|
||||
ok: boolean;
|
||||
stop?: boolean;
|
||||
errors?: ReadonlyArray<string>;
|
||||
};
|
||||
|
||||
export type OnPageHandler<T> = (
|
||||
items: T[],
|
||||
|
|
@ -64,8 +68,14 @@ export const forEachPage = async <T extends { id: string }>(
|
|||
const shouldStop = handlerResult?.stop === true;
|
||||
|
||||
if (!pageOk) {
|
||||
const perItemErrors = handlerResult?.errors ?? [];
|
||||
const detail =
|
||||
perItemErrors.length > 0
|
||||
? ` failures: ${perItemErrors.join(' | ')}`
|
||||
: '';
|
||||
|
||||
throw new Error(
|
||||
`Resend ${label} page ${pageNumber} reported per-item failures; aborting at cursor=${cursor ?? 'start'}`,
|
||||
`Resend ${label} page ${pageNumber} reported per-item failures; aborting at cursor=${cursor ?? 'start'}.${detail}`,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ export const syncBroadcasts = async (
|
|||
aggregate.updated += pageOutcome.result.updated;
|
||||
aggregate.errors.push(...pageOutcome.result.errors);
|
||||
|
||||
return { ok: pageOutcome.ok };
|
||||
return { ok: pageOutcome.ok, errors: pageOutcome.result.errors };
|
||||
},
|
||||
'broadcasts',
|
||||
{ startCursor: resumeCursor, onCursorAdvance },
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ export const syncContacts = async (
|
|||
aggregate.updated += pageOutcome.result.updated;
|
||||
aggregate.errors.push(...pageOutcome.result.errors);
|
||||
|
||||
return { ok: pageOutcome.ok };
|
||||
return { ok: pageOutcome.ok, errors: pageOutcome.result.errors };
|
||||
},
|
||||
'contacts',
|
||||
{ startCursor: resumeCursor, onCursorAdvance },
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ export const syncEmails = async (
|
|||
return {
|
||||
ok: pageOutcome.ok,
|
||||
stop: reachedCutoff,
|
||||
errors: pageOutcome.result.errors,
|
||||
};
|
||||
},
|
||||
'emails',
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ export const syncSegments = async (
|
|||
segmentIdMap.set(resendId, twentyId);
|
||||
}
|
||||
|
||||
return { ok: pageOutcome.ok };
|
||||
return { ok: pageOutcome.ok, errors: pageOutcome.result.errors };
|
||||
},
|
||||
'segments',
|
||||
{ startCursor: resumeCursor, onCursorAdvance },
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ export const syncTemplates = async (
|
|||
aggregate.updated += pageOutcome.result.updated;
|
||||
aggregate.errors.push(...pageOutcome.result.errors);
|
||||
|
||||
return { ok: pageOutcome.ok };
|
||||
return { ok: pageOutcome.ok, errors: pageOutcome.result.errors };
|
||||
},
|
||||
'templates',
|
||||
{ startCursor: resumeCursor, onCursorAdvance },
|
||||
|
|
|
|||
|
|
@ -81,8 +81,13 @@ export const syncTopics = async (
|
|||
}
|
||||
|
||||
if (!pageOutcome.ok) {
|
||||
const detail =
|
||||
pageOutcome.result.errors.length > 0
|
||||
? ` failures: ${pageOutcome.result.errors.join(' | ')}`
|
||||
: '';
|
||||
|
||||
throw new Error(
|
||||
'Resend topics page reported per-item failures; aborting',
|
||||
`Resend topics page reported per-item failures; aborting.${detail}`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue