Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinewi committed Jan 8, 2025
1 parent faf8928 commit a177b3f
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/api/transformArticleApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,26 @@ export const transformArticle = async (
footnoteCount += 1;
}
if (embed.data.resource === "uu-disclaimer") {
const transformedContent = await transformArticle(embed.data.disclaimer, context, undefined, {});
const uuDisclaimerEmbedData = {
resource: embed.data.resource,
data: { transformedContent: transformedContent.content },
status: "success",
embedData: embed.data,
} as EmbedMetaData;
embed.embed.attr("data-json", JSON.stringify(uuDisclaimerEmbedData));
return uuDisclaimerEmbedData;
try {
const transformedContent = await transformArticle(embed.data.disclaimer, context, undefined, {});
const uuDisclaimerEmbedData = {
resource: embed.data.resource,
data: { transformedContent: transformedContent.content },
status: "success",
embedData: embed.data,
} as EmbedMetaData;
embed.embed.attr("data-json", JSON.stringify(uuDisclaimerEmbedData));
return uuDisclaimerEmbedData;
} catch (e) {
const uuDisclaimerEmbedData = {
resource: embed.data.resource,
embedData: embed.data,
status: "error",
message: `Failed to fetch data for embed of type ${embed.data.resource} with index ${index}`,
} as EmbedMetaData;
embed.embed.attr("data-json", JSON.stringify(uuDisclaimerEmbedData));
return uuDisclaimerEmbedData;
}
}
return transformEmbed(embed, context, index, footnoteCount, {
subject,
Expand Down

0 comments on commit a177b3f

Please sign in to comment.