Skip to content

Commit

Permalink
Merge pull request #618 from techmatters/CHI-2666-import_logging_verb…
Browse files Browse the repository at this point in the history
…osity

CHI-2666: Ensure compactr JSON string is used in HRM resource error logs
  • Loading branch information
stephenhand authored Apr 5, 2024
2 parents 7c88cc8 + d9ef318 commit 86256bd
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions resources-domain/resources-service/src/import/importService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,16 @@ const importService = () => {
reason: 'missing field',
fields: missingFields,
};
err.resource = resource;
err.resourceJson = JSON.stringify(resource);
err.resourceId = resource.id;
throw err;
}
console.debug(`Upserting ${accountSid}/${resource.id}`);
const result = await upsert(accountSid, resource);
if (!result.success) {
const dbErr = new Error('Error inserting resource into database.') as any;
dbErr.resource = resource;
dbErr.resourceJson = JSON.stringify(resource);
dbErr.resourceId = resource.id;
dbErr.cause = result.error;
throw dbErr;
}
Expand Down Expand Up @@ -120,19 +122,19 @@ const importService = () => {
const error = e as any;
console.error(
`Failed to upsert ${accountSid}/${
error.resource?.id ?? 'unknown'
error.resourceId ?? 'unknown'
} - rolling back upserts in this message.`,
error,
);
await insertImportError()(
accountSid,
error.resource?.id,
error.resourceId,
batch,
serializeError(error),
resources,
);
if (error.validationFailure) {
return { ...error.validationFailure, resource: JSON.stringify(error.resource) };
return { ...error.validationFailure, resource: error.resourceJson };
}
throw error;
}
Expand Down

0 comments on commit 86256bd

Please sign in to comment.